Random numbers that follow a linear drop distribution in Python -
i'd generate random numbers follow dropping linear frequency distribution, take n=1-x example.
the numpy library seems offer more complex distributions.
so, turns out can totally use random.triangular(0,1,0)
this. see documentation here: https://docs.python.org/2/library/random.html
random.triangular(low, high, mode)
return random floating point number n such low <= n <= high , specified mode between bounds.
histogram made matplotlib
:
bins = [0.1 * in range(12)] plt.hist([random.triangular(0,1,0) in xrange(2500)], bins)
Comments
Post a Comment