def kruskal(*args):
 output = argstoarray(*args)
 ranks = ma.masked_equal(rankdata(output, use_missing=False), 0)
 sumrk = ranks.sum((-1))
 ngrp = ranks.count((-1))
 ntot = ranks.count()
 H = (((12.0 / (ntot * (ntot + 1))) * ((sumrk ** 2) / ngrp).sum()) - (3 * (ntot + 1)))
 ties = count_tied_groups(ranks)
 T = (1.0 - (np.sum(((v * ((k ** 3) - k)) for (k, v) in iteritems(ties))) / float(((ntot ** 3) - ntot))))
 if (T == 0):
  raise ValueError('All numbers are identical in kruskal')
 H /= T
 df = (len(output) - 1)
 prob = distributions.chi2.sf(H, df)
 return KruskalResult(H, prob)

def kruskal ( * args ) : output = argstoarray ( * args ) ranks = ma . masked_equal ( rankdata ( output , use_missing = False ) , 0 ) sumrk = ranks . sum ( ( - 1 ) ) ngrp = ranks . count ( ( - 1 ) ) ntot = ranks . count ( ) H = ( ( ( 12.0 / ( ntot * ( ntot + 1 ) ) ) * ( ( sumrk ** 2 ) / ngrp ) . sum ( ) ) - ( 3 * ( ntot + 1 ) ) ) ties = count_tied_groups ( ranks ) T = ( 1.0 - ( np . sum ( ( ( v * ( ( k ** 3 ) - k ) ) for ( k , v ) in iteritems ( ties ) ) ) / float ( ( ( ntot ** 3 ) - ntot ) ) ) ) if ( T == 0 ) : raise ValueError ( 'All numbers are identical in kruskal' ) H /= T df = ( len ( output ) - 1 ) prob = distributions . chi2 . sf ( H , df ) return KruskalResult ( H , prob )
compute the kruskal-wallis h-test for independent samples parameters sample1 .