def varcorrection_unbalanced(nobs_all, srange=False):
 nobs_all = np.asarray(nobs_all)
 if (not srange):
  return (1.0 / nobs_all).sum()
 else:
  return ((1.0 / nobs_all).sum() / len(nobs_all))

def varcorrection_unbalanced ( nobs_all , srange = False ) : nobs_all = np . asarray ( nobs_all ) if ( not srange ) : return ( 1.0 / nobs_all ) . sum ( ) else : return ( ( 1.0 / nobs_all ) . sum ( ) / len ( nobs_all ) )
correction factor for variance with unequal sample sizes this is just a harmonic mean parameters nobs_all : array_like the number of observations for each sample srange : bool if true .