[SciPy-dev] scipy.stats.chisquare insists second parameter is a numpy array

Jason Grout jason-sage at creativetrax.com
Fri Sep 18 12:12:30 EDT 2009


In the code for scipy.stats.chisquare, the first parameter is 
automatically converted to a numpy array, but the second parameter 
isn't; it is just used as if it were a numpy array.  Can the code be 
changed so that it does:

f_obs = asarray(f_obs)
k = len(f_obs)
if f_exp is None:
    f_exp = array([np.sum(f_obs,axis=0)/float(k)] * len(f_obs),float)
else:
    f_exp = asarray(f_exp,float)
chisq = np.add.reduce((f_obs-f_exp)**2 / f_exp)
return chisq, chisqprob(chisq, k-1)

This will allow the user to specify a normal python list for f_exp, I 
believe.

Thanks,

Jason

-- 
Jason Grout




More information about the SciPy-Dev mailing list