Random_Data_Generation_with_NumPy
Random_Data_Generation_with_NumPy
1. numpy.random.rand()
2. numpy.random.randn()
3. numpy.random.randint()
4. numpy.random.uniform()
5. numpy.random.normal()
import numpy as np
Output
[0.272784 0.09733427 0.457863 ]
Output
[ 0.04495402 -1.09919444 1.82620763]
1|Page
distribution (mean = 0, standard deviation = 1). The print statement
displays the generated array.
Example Code:
Output
[ 4 10 10 2 6]
import numpy as np
# Generate a random number between 2 and 5
random_number = np.random.uniform(2, 5)
print(random_number)
Output
4.833586883593855
2|Page
5. numpy.random.normal: Generates random numbers from a
normal (Gaussian) distribution with a specified mean and
standard deviation.
import numpy as np
Output
1.481601952386309
3|Page