My SciPy version is 1.7.3 and I'm running on an Apple M1 chip (not sure if it's relevant). My Python version is 3.9.11, installed via Annaconda.
I get the error message /opt/anaconda3/lib/python3.9/site-packages/scipy/stats/_continuous_distns.py:624: RuntimeWarning: overflow encountered in _beta_ppf return _boost._beta_ppf(q, a, b)
when running the following PyMC3 code:
import pymc3 as pm
from scipy import stats
Y = stats.bernoulli(0.7).rvs(20)
with pm.Model() as model:
theta = pm.Beta("theta", alpha=0.1, beta=0.1)
y_obs = pm.Binomial("y_obs", n=2, p=theta, observed=Y)
idata = pm.sample(1000, return_inferencedata=True)
I don't think the issue is with PyMC3, because the PyMC3 code someone else wrote runs without any errors:
np.random.seed(123)
n_experiments=4
theta_real =0.35
data =stats.bernoulli.rvs(p=theta_real,size=n_experiments)
with pm.Model() as our_first_model:
theta =pm.Beta('theta',alpha=1,beta=1)
y =pm.Bernoulli('y',p=theta,observed=data)
start =pm.find_MAP()
step =pm.Metropolis()
trace =pm.sample(1000,step=step,start=start)
burnin=100
chain =trace[burnin:]
pm.traceplot(chain,lines={'theta':theta_real})
The SciPy code snippet below, however, gives the same error:
import numpy as np
from scipy import stats
q = 0.999995
a = np.array([ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])
b = np.array([99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981])
stats.beta.ppf(q, a, b)
I Googled "overflow encountered in _beta_ppf
" and found a GitHub issue (https://github.com/scipy/scipy/issues/14901) that points to problems with SciPy <=1.7.2 on Intel chips. However, I'm using 1.7.3 on an M1 chip.
Anaconda doesn't allow me to update to the newest SciPy version (1.8.0). Using pip to update (pip install scipy==1.8.0
) results in incompatibilities with ArviZ (arviz 0.11.2 requires typing-extensions<4,>=3.7.4.3, but you have typing-extensions 4.1.1 which is incompatible
). I guess I could downgrade typing-extensions
, but it may cause further issues with other packages, so I'd rather not.
I wonder what I can do to solve this problem. Thanks!