def simultaneous_ci(q_crit, var, groupnobs, pairindices=None):
 ng = len(groupnobs)
 if (pairindices is None):
  pairindices = np.triu_indices(ng, 1)
 gvar = (var / groupnobs)
 d12 = np.sqrt((gvar[pairindices[0]] + gvar[pairindices[1]]))
 d = np.zeros((ng, ng))
 d[pairindices] = d12
 d = (d + d.conj().T)
 sum1 = np.sum(d12)
 sum2 = np.sum(d, axis=0)
 if (ng > 2):
  w = ((((ng - 1.0) * sum2) - sum1) / ((ng - 1.0) * (ng - 2.0)))
 else:
  w = ((sum1 * np.ones((2, 1))) / 2.0)
 return ((q_crit / np.sqrt(2)) * w)

def simultaneous_ci ( q_crit , var , groupnobs , pairindices = None ) : ng = len ( groupnobs ) if ( pairindices is None ) : pairindices = np . triu_indices ( ng , 1 ) gvar = ( var / groupnobs ) d12 = np . sqrt ( ( gvar [ pairindices [ 0 ] ] + gvar [ pairindices [ 1 ] ] ) ) d = np . zeros ( ( ng , ng ) ) d [ pairindices ] = d12 d = ( d + d . conj ( ) . T ) sum1 = np . sum ( d12 ) sum2 = np . sum ( d , axis = 0 ) if ( ng > 2 ) : w = ( ( ( ( ng - 1.0 ) * sum2 ) - sum1 ) / ( ( ng - 1.0 ) * ( ng - 2.0 ) ) ) else : w = ( ( sum1 * np . ones ( ( 2 , 1 ) ) ) / 2.0 ) return ( ( q_crit / np . sqrt ( 2 ) ) * w )
compute simultaneous confidence intervals for comparison of means .