Comments (7)
What version of mpmath do you have? Using 0.17, I get this:
In [26]: gammainc = vectorize(gammainc)
In [27]: x = arange(6,51)
In [28]: gammainc(1-2.45, .033*x)
Out[28]:
array([mpf('4.7254650873107051'), mpf('3.5574132536305769'),
mpf('2.7632640267912771'), mpf('2.1986605090749198'),
mpf('1.7831274678121478'), mpf('1.4687544156762053'),
mpf('1.2254992062468544'), mpf('1.0337152450792615'),
mpf('0.88009970283005678'), mpf('0.75537780707828139'),
mpf('0.65291978565420106'), mpf('0.56788337972645819'),
mpf('0.49666484074349937'), mpf('0.43653747013455607'),
mpf('0.38540772512153532'), mpf('0.34164703962281801'),
mpf('0.30397358868852165'), mpf('0.27136770907936236'),
mpf('0.24301044045076509'), mpf('0.21823822803465681'),
mpf('0.19650910210920391'), mpf('0.17737712575477133'),
mpf('0.16047287852110079'), mpf('0.14548840016396494'),
mpf('0.13216546714630714'), mpf('0.12028638548409158'),
mpf('0.10966670188705738'), mpf('0.10014939043977027'),
mpf('0.09160018378579142'), mpf('0.083903799013133412'),
mpf('0.076960868105193828'), mpf('0.070685427059029596'),
mpf('0.065002850862411296'), mpf('0.05984814647835663'),
mpf('0.055164534957336864'), mpf('0.050902268325669228'),
mpf('0.047017638102363639'), mpf('0.043472140994015217'),
mpf('0.040231774111453643'), mpf('0.037266437390975397'),
mpf('0.034549425122539223'), mpf('0.032056991840105457'),
mpf('0.029767980507127756'), mpf('0.027663503079465909'),
mpf('0.025726665261124014')], dtype=object)
How confident are you that those are the alpha and Lambda values that get to gammainc? If that really is the case, it may be an mpf issue.
from powerlaw.
I saw the issue with mpmath 0.17 from PyPI, as well as on yesterday's github master. I reproduced it again this evening using your pure mpmath/numpy code above.
Suspecting numpy 1.6.1, I moved over to numpy 1.7.1, and the problem went away (on github master) so I suspect the problem was something subtle in numpy.
Thanks for your help, and for the library. Lots of power laws and gamma distributions in atmospheric science, and this is really easy to use and well-supported by literature.
I'm closing the issue since this isn't a problem with powerlaw itself.
from powerlaw.
Disconcerting, but ok. Were you having this issue with one particular dataset, or virtually everything?
from powerlaw.
This happened again last night after I thought it was fixed. It took place when passing a float32 array into vectorized gammainc. Casting to float64 fixed it.
On Oct 25, 2013, at 6:19, jeffalstott [email protected] wrote:
Disconcerting, but ok. Were you having this issue with one particular dataset, or virtually everything?
—
Reply to this email directly or view it on GitHub.
from powerlaw.
Interesting. Is this just with that particular dataset?
On Fri, Oct 25, 2013 at 1:06 PM, deeplycloudy [email protected]:
This happened again last night after I thought it was fixed. It took place
when passing a float32 array into vectorized gammainc. Casting to float64
fixed it.On Oct 25, 2013, at 6:19, jeffalstott [email protected] wrote:
Disconcerting, but ok. Were you having this issue with one particular
dataset, or virtually everything?—
Reply to this email directly or view it on GitHub.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-27085033
.
from powerlaw.
It fails with a relatively generic test (positive or negative z)
In [4]: gammainc=np.vectorize(mpmath.gammainc)
In [5]: z = -1.9
In [6]: x=np.arange(.3, 50, .1)
In [7]: x.dtype
Out[7]: dtype('float64')
In [8]: gammainc(z,x)
Out[8]: array([mpf('3.0704147576940444'), mpf('1.5206831120098647'), ...
In [9]: gammainc(z,x.astype('f4'))
TypeError: cannot create mpf from 0.30000001
On Fri, Oct 25, 2013 at 7:11 AM, jeffalstott [email protected]:
Interesting. Is this just with that particular dataset?
On Fri, Oct 25, 2013 at 1:06 PM, deeplycloudy [email protected]:
This happened again last night after I thought it was fixed. It took
place
when passing a float32 array into vectorized gammainc. Casting to
float64
fixed it.On Oct 25, 2013, at 6:19, jeffalstott [email protected]
wrote:Disconcerting, but ok. Were you having this issue with one particular
dataset, or virtually everything?—
Reply to this email directly or view it on GitHub.—
Reply to this email directly or view it on GitHub<
https://github.com/jeffalstott/powerlaw/issues/6#issuecomment-27085033>
.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-27085436
.
from powerlaw.
Thanks for the info. You've successfully narrowed it down to being an mpmath issue. If you open an issue with them can you link it here?
https://github.com/fredrik-johansson/mpmath/
I don't know if they prefer there, their mailing list, or the Google Code site.
from powerlaw.
Related Issues (20)
- `estimate_discrete` should be False by default or raise a warning for x_min < 6 HOT 1
- p_value not computed from normalizes R HOT 6
- Issue with the x_min
- Curve fitted using power law is far from the data points
- Version label
- Added xmin computation does not work for distributions != power_law/truncated_power_law HOT 1
- power law plot showing fit and all data, not just data from xmin HOT 1
- New user: Why the curvature in power_law.plot_ccdf fit? HOT 14
- Defunct scipy import HOT 1
- threshold in powerlaw fit HOT 1
- Remove or make optional xmin fitting print
- Fitting a powerlaw with the xmax parameter HOT 17
- How to improve the efficiency of the fit.
- Get the estimates when i only have an probability distribution from empirical data
- Some issues in lognormal fit
- how to calculate the R value properly for discrete data
- Feature Request: Return the normalization constant HOT 9
- Please remove print statement on line 341 of powerlaw.py
- parameter1 attribute not set for fit.powerlaw HOT 1
- Can not pass 'bins' keyword to `plot_pdf` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powerlaw.