Closed embaldridge closed 10 years ago
Any thoughts on this @rueuntal?
Hi @embaldridge - sorry about the delay. I think the problem arises from rounding error when the upper bound is large, and the parameter estimate is extremely close to that from the untruncated case (i.e., S/N). I've modified the mode to hopefully prevent the error from creeping up. Note that the new code may give you slightly different (~e-14 or smaller difference, if I have to guess) parameter estimates compared to the old code. Let me know if it still doesn't work.
I think this is working: I'm not getting the error that I was before, although it seems to be running really slowly. I'm not sure if that is on my end or not, but I bet it is. I'm running pretty rough at the moment, so it will probably take me a couple of days to figure out what is actually going on.
I'm not surprised that it runs more slowly (though certainly wasn't expecting it to make too much of a difference), since optimize.bisect
in trunc_geom_solver
has to search over a larger interval. I've modified the code once again to make the searching interval smaller, hopefully this will help with speed while not running into rounding error.
The geometric distribution is being shelved for the moment. Something is up with getting some of the datasets to run anyway, so once I get that chased down, the geometric series might get added back in pretty quickly, as I suspect the problem is in a different area at this point.
Added back in, because the problem was not with the geometric series in the first place.
The BBS test sites seem to be working, script fails at the CBC sites, which are the next in line. Seems to be breaking at the truncated geometric solver.
[evaluate sad-comparisons.py] bbs, Site 4002, S=35, N=816 Optimization terminated successfully. Current function value: 128.802493 Iterations: 58 Function evaluations: 109 bbs, Site 4003, S=26, N=439 Optimization terminated successfully. Current function value: 95.126329 Iterations: 55 Function evaluations: 105 bbs, Site 4004, S=27, N=445 Optimization terminated successfully. Current function value: 99.606796 Iterations: 53 Function evaluations: 100 bbs, Site 4006, S=29, N=471 Optimization terminated successfully. Current function value: 99.362574 Iterations: 63 Function evaluations: 121 cbc, Site "L105249", S=57, N=7400 Warning: Maximum number of function evaluations has been exceeded. Traceback (most recent call last): File "/usr/lib/wingide-101-4.1/src/debug/tserver/_sandbox.py", line 146, in
File "/usr/lib/wingide-101-4.1/src/debug/tserver/_sandbox.py", line 89, in model_comparisons
File "/usr/local/lib/python2.7/dist-packages/macroecotools-0.2-py2.7.egg/macroeco_distributions/macroeco_distributions.py", line 462, in trunc_geom_solver
xtol = 1.490116e-08)
File "/usr/lib/python2.7/dist-packages/scipy/optimize/zeros.py", line 216, in bisect
r = _zeros._bisect(f,a,b,xtol,maxiter,args,full_output,disp)
ValueError: f(a) and f(b) must have different signs