You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def getData(c):
"""Initiate random data."""
import random
random.seed(9001)
np.random.seed(117)
x = np.array([0, 1, 2, 3, 4, 5])
y = np.array([i**2 + random.random() for i in x])
xerr = c * np.array([random.random() for i in x])
yerr = c * np.array([random.random() for i in x])
return x, y, xerr, yerr
x, y, xerr, yerr = getData(1.)
cov = np.zeros(len(x))
N_boot = 1000
a, b, erra, errb, covab = bcesboot(x, xerr, y, yerr, cov, N_boot)
Two thing I noticed:
There is an unused covar_ba variable defined in bces().
If I use bcesboot() with N_boot=1000 I get no warnings, but if I increase it to N=10000 (or more) I get multiple RuntimeWarning:
Bootstrapping progress:
bces_orig.py:54: RuntimeWarning: divide by zero encountered in double_scalars
a[1] = (y2.var() - sig22var)/(covar_y1y2 - sig12var) # X|Y
bces_orig.py:55: RuntimeWarning: invalid value encountered in double_scalars
a[2] = ( a[0]*a[1] - 1.0 + numpy.sqrt((1.0 + a[0]**2)*(1.0 + a[1]**2)) ) / (a[0]+a[1]) # bisector
bces_orig.py:60: RuntimeWarning: divide by zero encountered in double_scalars
a[3] = 0.5*((a[1]-(1./a[0])) + sign*numpy.sqrt(4.+(a[1]-(1./a[0]))**2)) # orthogonal
bces_orig.py:60: RuntimeWarning: invalid value encountered in double_scalars
a[3] = 0.5*((a[1]-(1./a[0])) + sign*numpy.sqrt(4.+(a[1]-(1./a[0]))**2)) # orthogonal
bces_orig.py:68: RuntimeWarning: invalid value encountered in subtract
xi.append( ( (y2-y2.mean()) * (y2-a[1]*y1-b[1]) - y2err**2 ) / covar_y1y2 ) # X|Y
bces_orig.py:69: RuntimeWarning: invalid value encountered in multiply
xi.append( xi[0] * (1.+a[1]**2)*a[2] / ((a[0]+a[1])*numpy.sqrt((1.+a[0]**2)*(1.+a[1]**2))) + xi[1] * (1.+a[0]**2)*a[2] / ((a[0]+a[1])*numpy.sqrt((1.+a[0]**2)*(1.+a[1]**2))) ) # bisector
bces_orig.py:70: RuntimeWarning: divide by zero encountered in double_scalars
xi.append( xi[0] * a[3]/(a[0]**2*numpy.sqrt(4.+(a[1]-1./a[0])**2)) + xi[1]*a[3]/numpy.sqrt(4.+(a[1]-1./a[0])**2) ) # orthogonal
bces_orig.py:70: RuntimeWarning: invalid value encountered in double_scalars
xi.append( xi[0] * a[3]/(a[0]**2*numpy.sqrt(4.+(a[1]-1./a[0])**2)) + xi[1]*a[3]/numpy.sqrt(4.+(a[1]-1./a[0])**2) ) # orthogonal
bces_orig.py:176: RuntimeWarning: invalid value encountered in double_scalars
erra[i]=numpy.sqrt( 1./(nsim-1) * ( numpy.sum(am[:,i]**2)-nsim*(am[:,i].mean())**2 ))
bces_orig.py:177: RuntimeWarning: invalid value encountered in double_scalars
errb[i]=numpy.sqrt( 1./(nsim-1) * ( numpy.sum(bm[:,i]**2)-nsim*(bm[:,i].mean())**2 ))
bces_orig.py:178: RuntimeWarning: invalid value encountered in double_scalars
covab[i]=1./(nsim-1) * ( numpy.sum(am[:,i]*bm[:,i])-nsim*am[:,i].mean()*bm[:,i].mean() )
The text was updated successfully, but these errors were encountered:
Dear @Gabriel-p,
Just wanted to let you know that I fixed this bug. This occurred for small datasets of just a few points, but now it is fixed in the latest version of the code. Give it a try.
I'm testing the code on some random data:
Two thing I noticed:
covar_ba
variable defined in bces().bcesboot()
withN_boot=1000
I get no warnings, but if I increase it toN=10000
(or more) I get multipleRuntimeWarning
:The text was updated successfully, but these errors were encountered: