#NEWLINE# @ lower ( 'np.random.wald' , types . Float , types . Float ) #NEWLINE# def wald_impl( context , builder , sig , args ) : #NEWLINE# #INDENT# def wald_impl( mean , scale ) : #NEWLINE# #INDENT# if ( mean <= 0.0 ) : #NEWLINE# #INDENT# raise ValueError ( 'wald(): mean <= 0' ) #NEWLINE# #UNINDENT# if ( scale <= 0.0 ) : #NEWLINE# #INDENT# raise ValueError ( 'wald(): scale <= 0' ) #NEWLINE# #UNINDENT# mu_2l = ( mean / ( 2.0 * scale ) ) #NEWLINE# Y = np . random . standard_normal ( ) #NEWLINE# Y = ( ( mean * Y ) * Y ) #NEWLINE# X = ( mean + ( mu_2l * ( Y - math . sqrt ( ( ( ( 4 * scale ) * Y ) + ( Y * Y ) ) ) ) ) ) #NEWLINE# U = np . random . random ( ) #NEWLINE# if ( U <= ( mean / ( mean + X ) ) ) : #NEWLINE# #INDENT# return X #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( ( mean * mean ) / X ) #NEWLINE# #UNINDENT# #UNINDENT# res = context . compile_internal ( builder , wald_impl , sig , args ) #NEWLINE# return impl_ret_untracked ( context , builder , sig . return_type , res )