xxxxxxxxxx
from numpy.random import normal, seed
seed(42)
# loc = mean, scale = standard deviation
random_numbers = normal(loc=0, scale=0.01, size=1000)
# Visualize the distribution of random numbers
from scipy.stats import norm
import seaborn as sns
sns.distplot(random_numbers, fit=norm, kde=False)
xxxxxxxxxx
>>> mu, sigma = 0, 0.1 # mean and standard deviation
>>> s = np.random.normal(mu, sigma, 1000)
xxxxxxxxxx
from scipy.stats import norm
# What percentage of man are shorter than 154
mean = 161
standard_deviation = 7
from scipy.stats import norm
norm.cdf(154, mean, standard_deviation)
xxxxxxxxxx
# Generate 10 random heights
mean = 161
standard_deviation = 7
from scipy.stats import norm
norm.rvs(mean, standard_deviation, size = 10)
xxxxxxxxxx
# What height are 90% of men are shorter than?
mean = 161
standard_deviation = 7
from scipy.stats import norm
norm.ppf(0.90, mean, standard_deviation)