def _chisquare(f_obs, f_exp):
 f_obs = np.asarray(f_obs, dtype=np.float64)
 k = len(f_obs)
 chisq = f_obs
 chisq -= f_exp
 chisq **= 2
 with np.errstate(invalid='ignore'):
  chisq /= f_exp
 chisq = chisq.sum(axis=0)
 return (chisq, special.chdtrc((k - 1), chisq))

def _chisquare ( f_obs , f_exp ) : f_obs = np . asarray ( f_obs , dtype = np . float64 ) k = len ( f_obs ) chisq = f_obs chisq -= f_exp chisq **= 2 with np . errstate ( invalid = 'ignore' ) : chisq /= f_exp chisq = chisq . sum ( axis = 0 ) return ( chisq , special . chdtrc ( ( k - 1 ) , chisq ) )
fast replacement for scipy .