def chisquare_effectsize(probs0, probs1, correction=None, cohen=True, axis=0):
 probs0 = np.asarray(probs0, float)
 probs1 = np.asarray(probs1, float)
 probs0 = (probs0 / probs0.sum(axis))
 probs1 = (probs1 / probs1.sum(axis))
 d2 = (((probs1 - probs0) ** 2) / probs0).sum(axis)
 if (correction is not None):
  (nobs, df) = correction
  diff = ((probs1 - probs0) / probs0).sum(axis)
  d2 = np.maximum(((((d2 * nobs) - diff) - df) / (nobs - 1.0)), 0)
 if cohen:
  return np.sqrt(d2)
 else:
  return d2

def chisquare_effectsize ( probs0 , probs1 , correction = None , cohen = True , axis = 0 ) : probs0 = np . asarray ( probs0 , float ) probs1 = np . asarray ( probs1 , float ) probs0 = ( probs0 / probs0 . sum ( axis ) ) probs1 = ( probs1 / probs1 . sum ( axis ) ) d2 = ( ( ( probs1 - probs0 ) ** 2 ) / probs0 ) . sum ( axis ) if ( correction is not None ) : ( nobs , df ) = correction diff = ( ( probs1 - probs0 ) / probs0 ) . sum ( axis ) d2 = np . maximum ( ( ( ( ( d2 * nobs ) - diff ) - df ) / ( nobs - 1.0 ) ) , 0 ) if cohen : return np . sqrt ( d2 ) else : return d2
effect size for a chisquare goodness-of-fit test parameters probs0 : array_like probabilities or cell frequencies under the null hypothesis probs1 : array_like probabilities or cell frequencies under the alternative hypothesis probs0 and probs1 need to have the same length in the axis dimension .