import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import math
mu = 0
variance = 1
sigma = math.sqrt(variance)
x = np.linspace(mu - 3 * sigma, mu + 3 * sigma, 100)
plt.plot(x, stats.norm.pdf(x, mu, sigma))
plt.show()
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)
# Generate 10 random heights
mean = 161
standard_deviation = 7
from scipy.stats import norm
norm.rvs(mean, standard_deviation, size = 10)
import numpy as np
import matplotlib.pyplot as plt
def get_normal(n):
mu,sigma = 10,1
s = np.random.normal(mu, sigma, n)
plt.hist(s, density=True)
plt.show()
get_normal(100)
# 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)
sns.histplot(x, stat='density')