# script ramdom_exponential.py ''' Generate exponentially distributed random numbers from uniforly distributed numbers .. author:: Guenter Quast ''' # dependencies: PYTHON v2.7, numpy, matplotlib # last modified: #-------------------------------------------------------------- # pyhton2 - python3 compatibility from __future__ import print_function, division, unicode_literals import numpy as np import matplotlib.pyplot as plt nr=10000 r=np.random.rand(nr) t=-np.log(r) # plot data as histogram nb=30 n, bins, patches = plt.hist(t, nb, \ density=1, alpha=0.5) plt.xlabel(r'$t=-\log(r)$', size='x-large') plt.ylabel('$probability$', size='x-large') plt.show()