Pseudo-randomizing events and methods
1. Pseudo-randomizing events and methods
In this video, we will learn methods to randomize events in discrete-event simulations.2. Process (or event) randomization
What is randomization? Randomization is the process of making something random, in this case, events (or processes). This is useful for representing non-deterministic processes in models. We should note that computers cannot generate truly random numbers since they rely on mathematical operations. External variables like time must be used to increase the randomness of number generators.3. Random vs. pseudo-random
We will focus on two types of randomizations, the "truly" random generation, where values are truly random within the intrinsic limits of the machine, and the pseudo-random generation, where numbers are generated based on probability distributions. In this case, the statistical distribution becomes apparent as the number of samples increases. Consider a factory with a manual assembly process. The graph shows the process duration to vary between 80 and 120 hours, so a probability distribution is more appropriate to generate a pseudo-random next occurrence that respects this statistics.4. Packages for pseudo-randomization
Several packages can randomize numbers, including NumPy, SciPy, statsmodels, pandas, Random, and scikit-learn. We will focus on the random package and its methods to generate random and pseudo-random numbers. You are likely familiar with statistical-distribution methods in Python and how they can be used to generate pseudo-random numbers. Here, we will focus only on the methods more commonly used in discrete-event models.5. Random number between given range
Let's start with the random generation of integers between a given range using random-dot-randint. Imagine we want to generate a number between three and nine. In this method, the starting number is included, but not the end number. Running the method returned five, but a different integer number will be produced on a new run. The random generation of float numbers between a given range is similar. It uses the random-dot-uniform method that takes the same input arguments, the start and end numbers of the desired range. Let's say we want to generate a float number also between three and nine. Running this method returned 6-point-45557754, but a different float number will be produced on a new run.6. Random samples and sequences
We can randomly sample from a sequence using the method random-dot-sample. Imagine we want to sample elements from a list named "mylist". k has been set to 2, meaning we want to sample two elements. Running this method returned a list with elements "cherry" and "banana", but a different combination will be returned on a new run. We can also shuffle a list using random-dot-shuffle. Running the method on the list named “mylist” returned a list with elements "eraser", "pencil", and "book", but elements will be re-ordered differently on a new run.7. Gaussian and exponential distributions
Now let's look at the pseudo-random generation of numbers using statistical distributions. The Gaussian and exponential distributions are commonly used in discrete-event models. The Gaussian distribution is also referred to as the Normal distribution. random-dot-gauss generates a float number based on the Gaussian distribution. It takes the average and standard deviation as input arguments. Running it for an average of 100 and a standard deviation of 50 returned 123-point-59382, but a different number will be produced on a new run. random-dot-expovariate generates a float number based on the Exponential distribution. If the input parameter lambda is positive, a positive number between zero and infinity is generated. If lambda is negative, a negative value between minus infinity and zero is generated. Running for a lambda of one-point-five, we obtained 0-point-2234355, but a different number will be generated on a new run.8. Let's practice!
Let's put these methods into practice.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.