numpy - Full-range random number in Python -


i'm generating series of random floats using line:

random.random()*(maxval-minval) + minval 

i'm using add variable noise given variable, , amount of noise added depends on series of factors. in cases, noise should high in practice original value lost, , have random value.

in context, code works works finite values, if use "inf" returns nan. there workaround allow continuos random range might include infinity? don't want tamper os.random() machine-specific.

after discussion in comments suggest following :

>>> m=sys.maxint >>> np.random.uniform(-m,m,5) array([ -5.32362215e+18,  -2.90131323e+18,   5.14492175e+18,         -5.64238742e+18,  -3.49640768e+18]) 

as said can max integer sys.maxint can use np.random.randint random number between maxint , -maxint.


Comments