Generating random numbers
You've used .sample()
to generate pseudo-random numbers from a set of values in a DataFrame. A related task is to generate random numbers that follow a statistical distribution, like the uniform distribution or the normal distribution.
Each random number generation function has distribution-specific arguments and an argument for specifying the number of random numbers to generate.
matplotlib.pyplot
is loaded as plt
, and numpy
is loaded as np
.
This exercise is part of the course
Sampling in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Generate random numbers from a Uniform(-3, 3)
uniforms = ____
# Print uniforms
print(uniforms)