Random Python module replace numpy.random.exponential?

I used the Numpy function numpy.random.exponentialfor a while. Now I see that the Python module randomhas many functions that I did not know about. Does he have something that replaces numpy.random.exponential? It would be nice to give up the requirement numpyof my project.

+3
source share
2 answers

If something about random.expovariate()doesn't suit your needs, it also easily collapses your own version:

def exponential(beta):
    return -beta * math.log(1.0 - random.random())

It seems like it's too much to be dependent on NumPy just for this feature.

, beta , NumPy, lambd of random.expovariate() beta.

+4

http://docs.python.org/library/random.html#random.expovariate

random.expovariate(lambd)

. lambd - 1,0 . . ( "", Python.) 0 , , 0, .

+3

All Articles