def _pval_from_histogram(T, H0, tail):
 if (tail not in [(-1), 0, 1]):
  raise ValueError('invalid tail parameter')
 if (tail == (-1)):
  pval = np.array([np.sum((H0 <= t)) for t in T])
 elif (tail == 1):
  pval = np.array([np.sum((H0 >= t)) for t in T])
 else:
  pval = np.array([np.sum((abs(H0) >= abs(t))) for t in T])
 pval = ((pval + 1.0) / (H0.size + 1.0))
 return pval

def _pval_from_histogram ( T , H0 , tail ) : if ( tail not in [ ( - 1 ) , 0 , 1 ] ) : raise ValueError ( 'invalid tail parameter' ) if ( tail == ( - 1 ) ) : pval = np . array ( [ np . sum ( ( H0 <= t ) ) for t in T ] ) elif ( tail == 1 ) : pval = np . array ( [ np . sum ( ( H0 >= t ) ) for t in T ] ) else : pval = np . array ( [ np . sum ( ( abs ( H0 ) >= abs ( t ) ) ) for t in T ] ) pval = ( ( pval + 1.0 ) / ( H0 . size + 1.0 ) ) return pval
get p-values from stats values given an h0 distribution .