def chisquare_power(effect_size, nobs, n_bins, alpha=0.05, ddof=0):
 crit = stats.chi2.isf(alpha, ((n_bins - 1) - ddof))
 power = stats.ncx2.sf(crit, ((n_bins - 1) - ddof), ((effect_size ** 2) * nobs))
 return power

def chisquare_power ( effect_size , nobs , n_bins , alpha = 0.05 , ddof = 0 ) : crit = stats . chi2 . isf ( alpha , ( ( n_bins - 1 ) - ddof ) ) power = stats . ncx2 . sf ( crit , ( ( n_bins - 1 ) - ddof ) , ( ( effect_size ** 2 ) * nobs ) ) return power
power of chisquare goodness of fit test effect size is sqrt of chisquare statistic divided by nobs parameters effect_size : float this is the deviation from the null of the normalized chi_square statistic .