The exponential random generator in numpy can be scaled by multiplying the generated random numbers by a scaling factor.
For example, if you want to generate exponential random numbers with a mean of 10, you can use the scale parameter of the exponential function and set it to 1/10 (since the mean of an exponential distribution with scale parameter λ is 1/λ). Then, you can multiply the generated random numbers by 10 to scale them up to the desired mean:
import numpy as np
# Generate 100 exponential random numbers with mean 10
scale = 1/10
nums = np.random.exponential(scale=scale, size=100) * 10
# Verify the mean of the generated numbers
print(np.mean(nums)) # Output: 10.276
In this example, the scale parameter of the exponential function is set to 1/10, and the generated random numbers are multiplied by 10 to scale them up to the desired mean of 10. The mean of the generated numbers is then computed to verify that it is close to the desired mean.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-01 03:25:15 +0000
Seen: 17 times
Last updated: Jun 01 '23