Comments (4)
Thanks for the report. Could you elaborate with a minimal working example for which parameter values the error occurs? I have a hard time interpreting the Wolfram Alpha computarion. The same holds for the other issue you opened.
from scipy.
Thanks for adding the MWE, that helps a lot.
from scipy.
For example, if the following code is executed:
import numpy as np
import scipy.stats as stats
x = np.arange(0, 16).astype(np.int32)
dist = stats.zipf(9.0)
pmf = dist.pmf(x)
print(pmf)
The values are as expected.
[0.00000000e+00 9.97995633e-01 1.94921022e-03 5.07034310e-05
3.80705121e-06 5.10973764e-07 9.90301387e-08 2.47312621e-08
7.43564690e-09 2.57600117e-09 9.97995633e-10 4.23247571e-10
1.93418240e-10 9.41105843e-11 4.83032464e-11 2.59601567e-11]
However, if the shape parameter is an integer, an incorrect value is obtained for x>=11, as shown below.
import numpy as np
import scipy.stats as stats
x = np.arange(0, 16).astype(np.int32)
dist = stats.zipf(9)
pmf = dist.pmf(x)
print(pmf)
[0.00000000e+00 9.97995633e-01 1.94921022e-03 5.07034310e-05
3.80705121e-06 5.10973764e-07 9.90301387e-08 2.47312621e-08
7.43564690e-09 2.57600117e-09 9.97995633e-10 0.00000000e+00
1.15400158e-09 4.95390192e-10 0.00000000e+00 0.00000000e+00]
When executing the following lines
_discrete_distns.py L1309
def _pmf(self, k, a):
# zipf.pmf(k, a) = 1/(zeta(a) * k**a)
Pk = 1.0 / special.zeta(a, 1) / k**a
return Pk
The input value k and the shape parameter a are both integer types, which may be causing the overflow.
from scipy.
That is indeed the issue. The maximum value for int32 is *k**-a
instead. Would you be interested in drafting a PR?
from scipy.
Related Issues (20)
- BUG: incorrect origin tuple handling in ndimage `minimum_filter` and `maximum_filter` with footprint covering a subset of axes
- BUG: stats.weibull_min: poor fit results on shape parameters HOT 2
- BUG: spatial: `Rotation.align_vectors()` incorrect for anti-parallel vectors HOT 1
- MAINT, TST: failure in test_axis_nan_policy_decorated_positional_args with array API HOT 2
- DOC: Missing blankspace in error message raised by cont2discrete()
- BLD: cross build scipy 1.13.0 with numpy 2.0.0rc1 using pip install failed HOT 6
- Tracker: Support Python nogil builds
- BUG: sparse matrix creation in 1.13 with indices not summing entries any more HOT 2
- DOC: A typo in authors name in signal.ellipap reference
- ENH: signal: add array API support
- Cannot import scipy.linalg.triu HOT 8
- BUG: signal.correlate: many numerical close-to-zero errors on 3D array HOT 1
- RFC: Switch to `cython_<lapack,blas>` based wrappers and deprecate custom `scipy.linalg.<lapack,blas>` HOT 2
- DOC: A typo in ValueError raised by signal.iirdesign HOT 2
- `cuve_fit` results are inconsistent over different CPU / Linux distro HOT 3
- ENH: spatial: Matrix multiplication of Rotation HOT 3
- ENH: Reintroduce Apple Accelerate support HOT 2
- BUG: stats.noncentral_t: incorrect pdf values HOT 6
- BUG: special: algorithmic Error in `ratevl` in `cephes/polevl.h` HOT 13
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 scipy.