fitter icon indicating copy to clipboard operation
fitter copied to clipboard

Example from readthedocs not working even if I downsample the array

Open miguelcarcamov opened this issue 4 years ago • 3 comments
trafficstars

Hello, I am trying to run the example from readthedocs which is:

from scipy import stats
data = stats.gamma.rvs(2, loc=1.5, scale=2, size=100000)

from fitter import Fitter
f = Fitter(data, timeout=3000, distributions=['gamma', 'rayleigh', 'uniform']) #Increasing time out time
f.fit()
f.summary()

and I am getting:

WARNING:root:SKIPPED uniform distribution (taking more than 3000 seconds)

WARNING:root:SKIPPED rayleigh distribution (taking more than 3000 seconds)

/home/miguel/.local/lib/python3.9/site-packages/scipy/stats/_continuous_distns.py:4530: IntegrationWarning: The integral is probably divergent, or slowly convergent.
  intg = integrate.quad(f, -xi, np.pi/2, **intg_kwargs)[0]
WARNING:root:SKIPPED gamma distribution (taking more than 3000 seconds)

WARNING:fitter.fitter:uniform was not fitted. no parameters available
WARNING:fitter.fitter:rayleigh was not fitted. no parameters available
WARNING:fitter.fitter:gamma was not fitted. no parameters available
WARNING:matplotlib.legend:No handles with labels found to put in legend.

My version of fitter from pip is 1.3.0...

Am I doing something wrong? The example from the readthedocs should work in principle right?

Also, I was thinking that there might a bug with the timeout parameter? no matter how much time I give it, it always returns SKIPPED x distribution (taking more than y seconds), where y can be a very large number.

miguelcarcamov avatar Jun 17 '21 10:06 miguelcarcamov

The same happened to me. testing with a simple example. I tried varying the initial data distribution parameters.

MigueLesPaul avatar Aug 19 '21 01:08 MigueLesPaul

@miguelcarcamov I ran you your data and it gives me result without any skipping. I was using fitter 1.3.0 Out[6]: sumsquare_error aic bic kl_div gamma 0.000073 1494.092341 -2.103890e+06 inf rayleigh 0.018802 2858.246376 -1.548651e+06 inf uniform 0.278573 711.116338 -1.279077e+06 inf

kabirmdasraful avatar Aug 24 '21 13:08 kabirmdasraful

@MigueLesPaul @miguelcarcamov I'm sorry about that. This is strange. On version 1.3.0 and 1.4.0 I got the answer in a fraction of a second repeatedly. It will be difficult to debug this on my side. Please make sure scipy is up-to-date. Try with 10,000 sample then 1,000 and see it converges but I'm still puzzled that it does not work. I see that you are under python3.9; maybe there is an issue with python3.9 not sure. I have added 3.9 to the continuous integration to see whether this work at least on github.

cokelaer avatar Sep 02 '21 19:09 cokelaer