Member-only story
Simulating randomness using Python’s NumPy random module
4 min readMar 17, 2020
Randomness exists everywhere. This tutorial will explain how to simulate randomness using Python’s NumPy random module. Interested readers can read the tutorial on simulating randomness using Python’s random module from the following link.
Generate a random number from a standard uniform distribution between 0 and 1
import numpy as np # import required packager = np.random.random()print(r)
The output of the above print statement will be a number in [0, 1].
Generate a 1D array with n × n random numbers from a standard uniform distribution between 0 and 1
n = 10 # specify number of elementsrandom_array1d = np.random.random(n)print(random_array1d)
The output of the above print statement is:
[0.62162451 0.9928667…