#NEWLINE# def test_multinomial_n_samples( ) : #NEWLINE# #INDENT# mode_ = mode #NEWLINE# if ( mode == 'FAST_COMPILE' ) : #NEWLINE# #INDENT# mode_ = 'FAST_RUN' #NEWLINE# #UNINDENT# if ( ( mode in [ 'DEBUG_MODE' , 'DebugMode' , 'FAST_COMPILE' ] ) or ( ( mode == 'Mode' ) and ( config . linker in [ 'py' ] ) ) ) : #NEWLINE# #INDENT# sample_size = ( 49 , 5 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sample_size = ( 450 , 6 ) #NEWLINE# #UNINDENT# mode_ = theano . compile . mode . get_mode ( mode_ ) #NEWLINE# pvals = numpy . asarray ( numpy . random . uniform ( size = sample_size ) ) #NEWLINE# pvals = numpy . apply_along_axis ( ( lambda row : ( row / numpy . sum ( row ) ) ) , 1 , pvals ) #NEWLINE# R = MRG_RandomStreams ( 234 , use_cuda = False ) #NEWLINE# for ( n_samples , steps ) in zip ( [ 5 , 10 , 100 , 1000 ] , [ 20 , 10 , 1 , 1 ] ) : #NEWLINE# #INDENT# m = R . multinomial ( pvals = pvals , n = n_samples , dtype = config . floatX , nstreams = ( 30 * 256 ) ) #NEWLINE# f = theano . function ( [ ] , m , mode = mode_ ) #NEWLINE# basic_multinomialtest ( f , steps , sample_size , R , n_samples , prefix = 'mrg ' ) #NEWLINE# sys . stdout . flush ( ) #NEWLINE# if ( ( mode != 'FAST_COMPILE' ) and cuda_available ) : #NEWLINE# #INDENT# R = MRG_RandomStreams ( 234 , use_cuda = True ) #NEWLINE# pvals = numpy . asarray ( pvals , dtype = 'float32' ) #NEWLINE# n = R . multinomial ( pvals = pvals , n = n_samples , dtype = 'float32' , nstreams = ( 30 * 256 ) ) #NEWLINE# assert ( n . dtype == 'float32' ) #NEWLINE# f = theano . function ( [ ] , theano . sandbox . cuda . basic_ops . gpu_from_host ( n ) , mode = mode_ . including ( 'gpu' ) ) #NEWLINE# sys . stdout . flush ( ) #NEWLINE# basic_multinomialtest ( f , steps , sample_size , pvals , n_samples , prefix = 'gpu mrg ' )