def achisquare(f_obs,f_exp=None):

    k = len(f_obs)
    if f_exp == None:
        f_exp = N.array([sum(f_obs)/float(k)] * len(f_obs),N.float_)
    f_exp = f_exp.astype(N.float_)
    chisq = N.add.reduce((f_obs-f_exp)**2 / f_exp)
    return chisq, achisqprob(chisq, k-1)
Calculates a one-way chi square for array of observed frequencies and returns
dataset/ETHPy150Open radlab/sparrow/src/main/python/third_party/stats.py/achisquare