In [10]:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.stats import norm
%matplotlib inline
mpl.rcParams['savefig.dpi'] = 80
mpl.rcParams['figure.figsize'] = (6,9)
# plt.style.use('fivethirtyeight')
plt.style.use('seaborn')
# change the range to cut off one end or other of the curve
x = np.arange(-10, 10, 0.001)
# Mean = 0, SD = 1.
y = norm.pdf(x,0,1)
fig, ax = plt.subplots()
ax.fill_between(x,y,0, alpha=0.5)
plt.xlim([-4,4])
plt.title('Normal Gaussian Curve')
plt.show()
In [14]:
mu = 998.8
sigma = 72.1
x1 = 990
x2 = 1100
z1 = ( x1 - mu ) / sigma
z2 = ( x2 - mu ) / sigma
# change the range to cut off one end or other of the curve
x = np.arange(z1, z2, 0.001)
# Mean = 0, SD = 1.
y = norm.pdf(x,0,1)
fig, ax = plt.subplots()
ax.fill_between(x,y,0, alpha=0.5)
plt.xlim([-4,4])
plt.xlabel('# of standard deviations outside the mean')
plt.title('Normal Gaussian Curve')
plt.show()
In [15]:
#plt.style.use('fivethirtyeight')
mu = 998.8
sigma = 72.1
x1 = 990
x2 = 1100
z1 = ( x1 - mu ) / sigma
z2 = ( x2 - mu ) / sigma
# change the range to cut off one end or other of the curve
x = np.arange(z1, z2, 0.001)
x_all = np.arange(-10, 10, 0.001)
# Mean = 0, SD = 1.
y = norm.pdf(x,0,1)
y2 = norm.pdf(x_all,0,1)
fig, ax = plt.subplots()
ax.plot(x_all,y2)
ax.fill_between(x,y,0, alpha=0.5)
ax.fill_between(x_all,y2,0, alpha=0.2)
plt.xlim([-4,4])
plt.xlabel('# of standard deviations outside the mean')
plt.title('Normal Gaussian Curve')
plt.savefig('area_under_normal_curve_plot.png')
plt.show()
In [ ]: