Generating Random Numbers With Numpy

Want to learn more? I recommend these Python books: Python for Data Analysis, Python Data Science Handbook, and Introduction to Machine Learning with Python.

Import Numpy

import numpy as np

Generate A Random Number From The Normal Distribution


Generate Four Random Numbers From The Normal Distribution

array([-1.03175853,  1.2867365 , -0.23560103, -1.05225393])

Generate Four Random Numbers From The Uniform Distribution

array([ 0.00193123,  0.51932356,  0.87656884,  0.33684494])

Generate Four Random Integers Between 1 and 100

np.random.randint(low=1, high=100, size=4)
array([96, 25, 94, 77])