def rayleightest(data, axis=None, weights=None):
 n = np.size(data, axis=axis)
 Rbar = _length(data, 1, 0.0, axis, weights)
 z = ((n * Rbar) * Rbar)
 tmp = 1.0
 if (n < 50):
  tmp = ((1.0 + (((2.0 * z) - (z * z)) / (4.0 * n))) - (((((24.0 * z) - (132.0 * (z ** 2.0))) + (76.0 * (z ** 3.0))) - (9.0 * (z ** 4.0))) / ((288.0 * n) * n)))
 p_value = (np.exp((- z)) * tmp)
 return p_value

def rayleightest ( data , axis = None , weights = None ) : n = np . size ( data , axis = axis ) Rbar = _length ( data , 1 , 0.0 , axis , weights ) z = ( ( n * Rbar ) * Rbar ) tmp = 1.0 if ( n < 50 ) : tmp = ( ( 1.0 + ( ( ( 2.0 * z ) - ( z * z ) ) / ( 4.0 * n ) ) ) - ( ( ( ( ( 24.0 * z ) - ( 132.0 * ( z ** 2.0 ) ) ) + ( 76.0 * ( z ** 3.0 ) ) ) - ( 9.0 * ( z ** 4.0 ) ) ) / ( ( 288.0 * n ) * n ) ) ) p_value = ( np . exp ( ( - z ) ) * tmp ) return p_value
performs the rayleigh test of uniformity .