Mar-31-2019, 03:40 AM
Dear experts,
I am working with a probability density function (PDF), that I named as "Jaya", as below:
f(x) = scale**(shape-1) * x**(-shape)*(np.exp(-scale/x)) / math.factorial(shape - 2)
I would like to know how can I create a function to generate random number based on the above PDF.
One example is the numpy.random.gamma that follows the Gamma PDF as below.
f(x) = x**(shape-1)*(np.exp(-bins/scale) / (sps.gamma(shape)*scale**shape))
I am working with a probability density function (PDF), that I named as "Jaya", as below:
f(x) = scale**(shape-1) * x**(-shape)*(np.exp(-scale/x)) / math.factorial(shape - 2)
I would like to know how can I create a function to generate random number based on the above PDF.
One example is the numpy.random.gamma that follows the Gamma PDF as below.
f(x) = x**(shape-1)*(np.exp(-bins/scale) / (sps.gamma(shape)*scale**shape))
import numpy as np import matplotlib.pyplot as plt import scipy.special as sps import math shape, scale = 3, 10**-6. s = np.random.gamma(shape, scale, 1000) count, bins, ignored = plt.hist(s, 50, density=True) #____________Gamma y = bins**(shape-1)*(np.exp(-bins/scale) / (sps.gamma(shape)*scale**shape)) plt.plot(bins, y, linewidth=2, color='r') plt.show() #____________Jaya y = scale**(shape-1) * bins**(-shape)*(np.exp(-scale/bins)) / math.factorial(shape - 2) plt.plot(bins, y, linewidth=1, color='r') plt.show()Thank you!