def weightedUtest(g1, w1, g2, w2):
 from scipy.stats.distributions import norm
 import numpy
 n1 = sum(w1)
 n2 = sum(w2)
 u1 = 0.0
 for (x1, wx1) in zip(g1, w1):
  for (x2, wx2) in zip(g2, w2):
   if (x1 == x2):
    u1 += ((0.5 * wx1) * wx2)
   elif (x1 > x2):
    u1 += (wx1 * wx2)
 mu = ((n1 * n2) / 2.0)
 sigu = numpy.sqrt((((n1 * n2) * ((n1 + n2) + 1)) / 12.0))
 z = ((u1 - mu) / sigu)
 conf = norm.cdf(z)
 return conf

def weightedUtest ( g1 , w1 , g2 , w2 ) : from scipy . stats . distributions import norm import numpy n1 = sum ( w1 ) n2 = sum ( w2 ) u1 = 0.0 for ( x1 , wx1 ) in zip ( g1 , w1 ) : for ( x2 , wx2 ) in zip ( g2 , w2 ) : if ( x1 == x2 ) : u1 += ( ( 0.5 * wx1 ) * wx2 ) elif ( x1 > x2 ) : u1 += ( wx1 * wx2 ) mu = ( ( n1 * n2 ) / 2.0 ) sigu = numpy . sqrt ( ( ( ( n1 * n2 ) * ( ( n1 + n2 ) + 1 ) ) / 12.0 ) ) z = ( ( u1 - mu ) / sigu ) conf = norm . cdf ( z ) return conf
determines the confidence level of the assertion: the values of g2 are higher than those of g1 .