#NEWLINE# @ lower ( 'random.triangular' , types . Float , types . Float ) #NEWLINE# def triangular_impl_2( context , builder , sig , args ) : #NEWLINE# #INDENT# fltty = sig . return_type #NEWLINE# ( low , high ) = args #NEWLINE# state_ptr = get_state_ptr ( context , builder , 'py' ) #NEWLINE# randval = get_next_double ( context , builder , state_ptr ) #NEWLINE# def triangular_impl_2( randval , low , high ) : #NEWLINE# #INDENT# u = randval #NEWLINE# c = 0.5 #NEWLINE# if ( u > c ) : #NEWLINE# #INDENT# u = ( 1.0 - u ) #NEWLINE# ( low , high ) = ( high , low ) #NEWLINE# #UNINDENT# return ( low + ( ( high - low ) * math . sqrt ( ( u * c ) ) ) ) #NEWLINE# #UNINDENT# res = context . compile_internal ( builder , triangular_impl_2 , signature ( * ( ( fltty , ) * 4 ) ) , ( randval , low , high ) ) #NEWLINE# return impl_ret_untracked ( context , builder , sig . return_type , high )