I am trying to create random numbers that follow the exponential distribution. The numbers should be between 0 and 18353. I am using the following code:
np.random.exponential(2400, 400)
which means that the output has 400 numbers and the scale parameter is 2400. However, 2400 is my estimation of the scaling parameter by plotting the random numbers.
sns.kdeplot(np.random.exponential(2000, 400))
sns.kdeplot(np.random.exponential(2400, 400))
sns.kdeplot(np.random.exponential(2300, 400))
plt.legend([r"$\beta = 1$",
r"$\beta = 2$",
r"$\beta = 3$"])
plt.show()
Is there anyway to calculate the scale parameter so that it gives us the numbers in a specific range?
You can't firmly restrict the upper bound of the random values drawn from an exponential distribution (see comment above).
Given the quantile formula for the exponential distribution (with lambda = 1 / beta) you can calculate the scale parameter beta
so that in average say 99.9 % of the values are less than 18353:
beta = -18353/np.log(1 - 0.999)
a = np.random.exponential(beta, 400)