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) 

enter image description here


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -