You can use the random
module combined with the numpy
library to generate random numbers from a normal distribution with a mean of 0 and a standard deviation of 1 in Python. Here's some example code:
main.py390 chars16 lines
In this code, we first set the mean mu
and standard deviation sigma
of the normal distribution. We then use the numpy
library to generate a random number from the normal distribution using the normal()
function. Alternatively, we use the random
module to generate a random number from the standard normal distribution using the gauss()
function. Finally, we print the random numbers to the console.
gistlibby LogSnag