def g_fit(data, williams=True):
 r_data = [array(i).mean() for i in data]
 (G, p) = power_divergence(r_data, lambda_='log-likelihood')
 if williams:
  G_corr = williams_correction(sum(r_data), len(r_data), G)
  return (G_corr, chi2prob(G_corr, (len(r_data) - 1), direction='high'))
 else:
  return (G, p)

def g_fit ( data , williams = True ) : r_data = [ array ( i ) . mean ( ) for i in data ] ( G , p ) = power_divergence ( r_data , lambda_ = 'log-likelihood' ) if williams : G_corr = williams_correction ( sum ( r_data ) , len ( r_data ) , G ) return ( G_corr , chi2prob ( G_corr , ( len ( r_data ) - 1 ) , direction = 'high' ) ) else : return ( G , p )
calculate the g statistic aka log-likelihood ratio test .