October 2019
Beginner to intermediate
674 pages
16h 43m
English
The random module of the NumPy package packs within it a whole range of functions for random sampling that perform operations right from creating a simple array of random numbers to drawing random samples from distribution functions.
The random.rand function generates random values from 0 to 1 (uniform distribution) to create an array of given shape:
# Creating a random array with 2 rows and 4 columns, from a uniform distributionIn [49]: np.random.rand(2, 4)Out [49]:array([[0.06573958, 0.32399347, 0.60926818, 0.99319404],[0.46371691, 0.49197909, 0.93103333, 0.06937098]])
The random.randn function samples values from a standard normal distribution to build an array of given shape. If the shape parameter is not specified, ...
Read now
Unlock full access