I'm currently working on a kinetic Monte Carlo simulation in Python, so I need to generate pseudo-random numbers between 0 and 1 that follow the uniform distribution, but I'm searching to obtain at some point numbers less than E-1, for example, 0.001. I know that it won't be common, because they are random numbers after all, but my problem started in the implementation of Monte Carlo.
The problem in my Monte Carlo simulation, briefly is, I have one constraint_probability=c and one pseudo-random number=r, but because of the dynamics of my problem, I have the condition that my code only run if r < c. If I make for example c=0.001, my code never run.
My first thought was to use random.uniform, but I found that the numbers obtained were at least with an order of E-2.
Later, I thought that my problem could be solved by making the following function:
from scipy.stats import uniform
def numrand():
vec=np.linspace(uniform.ppf(0),uniform.ppf(1), 10000)
return random.choice(vec)
I don't know if it's possible to obtain random numbers less than E-1 or if is another way to make my code run.
numpy.random can likely help you here, to create 10000 random numbers between 0 and 1 with uniform distribution you can use
or for older numpy versions: