#NEWLINE# @ lower ( 'np.random.negative_binomial' , types . int64 , types . Float ) #NEWLINE# def negative_binomial_impl( context , builder , sig , args ) : #NEWLINE# #INDENT# _gamma = np . random . gamma #NEWLINE# _poisson = np . random . poisson #NEWLINE# def negative_binomial_impl( n , p ) : #NEWLINE# #INDENT# if ( n <= 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'negative_binomial(): n <= 0' ) #NEWLINE# #UNINDENT# if ( ( p < 0.0 ) or ( p > 1.0 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'negative_binomial(): p outside of [0, 1]' ) #NEWLINE# #UNINDENT# Y = _gamma ( n , ( ( 1.0 - p ) / p ) ) #NEWLINE# return _poisson ( Y ) #NEWLINE# #UNINDENT# res = context . compile_internal ( builder , negative_binomial_impl , sig , context ) #NEWLINE# return impl_ret_untracked ( context , builder , sig . return_type , res )