IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Sampling in Python

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Generate random numbers from a Uniform(-3, 3)
uniforms = ____

# Print uniforms
print(uniforms)
Modifica ed esegui il codice