Randomizing values
In this exercise, you will apply and examine different randomization methods. The objective is to make you comfortable with different methods and how they impact the way random numbers are generated. Each of these methods will be useful in different situations, so it is important to understand their differences.
Imagine you have a business process that takes about 15 minutes to complete. However, you know that the actual duration varies by approximately five minutes (up or down). Apply the different randomizing methods from the random
package to generate variations of this duration in a controlled way.
This exercise is part of the course
Discrete Event Simulation in Python
Exercise instructions
- Generate 1000 random process durations as integer numbers based on the information provided.
- Generate 1000 random process durations as float numbers based on the information provided.
- Generate 1000 pseudo-random durations as float numbers based on a Gaussian distribution with a mean and standard deviation of 15 and 5, respectively.
- Generate 1000 pseudo-random durations as float numbers based on an exponential distribution with a lambda parameter of 1.5 (positive) and a peak at 15.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Generate random integer numbers
randint_array = np.array([____ for i in range(1000)])
# Generate random float numbers
uniform_array = np.array([____ for i in range(1000)])
# Generate random float numbers based on the Gaussian distribution
gauss_array = np.array([____ for i in range(1000)])
# Generate random float numbers based on the Exponential distribution
expon_array = np.array([____ + 15 for i in range(1000)])
plot_all(randint_array, uniform_array, gauss_array, expon_array)