random number generation

Jah_Alarm jah.alarm at gmail.com
Tue Aug 17 02:37:45 CEST 2010


hi,

I need to generate a binary array with a specified average proportion
of 1s (e.g. [1 0 0 0
 
0 1 0 0] has this proportion = 25%). In Matlab I run something like
random(m,n)<p where p is the value

between 0 and 1. I'm trying to use random.randint(0,2,size=[m,n]), but
I don't understand how to specify this proportion p.

thanks,

Alex



More information about the Python-list mailing list