#NEWLINE# def test_rvs( self ) : #NEWLINE# #INDENT# states = [ ( - 1 ) , 0 , 1 , 2 , 3 , 4 ] #NEWLINE# probability = [ 0.0 , 0.3 , 0.4 , 0.0 , 0.3 , 0.0 ] #NEWLINE# samples = 1000 #NEWLINE# r = stats . rv_discrete ( name = 'sample' , values = ( samples , probability ) ) #NEWLINE# x = r . rvs ( size = samples ) #NEWLINE# assert_ ( isinstance ( x , numpy . ndarray ) ) #NEWLINE# for ( s , p ) in zip ( states , probability ) : #NEWLINE# #INDENT# assert_ ( ( abs ( ( ( sum ( ( x == s ) ) / float ( samples ) ) - p ) ) < 0.05 ) ) #NEWLINE# #UNINDENT# x = r . rvs ( ) #NEWLINE# assert_ ( isinstance ( x , int ) )