From 83b9f8fefdf9b585b34f3e0c2b846b5c16d40a3b Mon Sep 17 00:00:00 2001 From: Boyuan Ning <73546421+ningboyuan@users.noreply.github.com> Date: Sun, 13 Mar 2022 03:29:31 +0100 Subject: [PATCH] Update NormalDistributions_CDF.py --- .../NormalDistributions_CDF.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DEDA_Class_2017_Statistics&Finance/NormalDistributions_CDF.py b/DEDA_Class_2017_Statistics&Finance/NormalDistributions_CDF.py index 6bcdcc3..94399cd 100644 --- a/DEDA_Class_2017_Statistics&Finance/NormalDistributions_CDF.py +++ b/DEDA_Class_2017_Statistics&Finance/NormalDistributions_CDF.py @@ -1,17 +1,18 @@ import scipy as sc import matplotlib.pyplot as plt import matplotlib.mlab as mlab - +from scipy.stats import norm +\ def plot_normal(mu, sigma, size): # Create a function to receive normal distribution parameters normal_data = sc.random.normal(loc=mu, scale=sigma, size=size) - plt.axes() + # The hist() method not only draw the histogram # but also return the info of the drawing - n, bins, patchs = plt.hist(normal_data, bins=100, normed=1) + n, bins, patchs = plt.hist(normal_data, bins=100, density=True) # Use bins returned from hist() to draw a wrap line - y = mlab.normpdf(bins, mu, sigma) + y = norm.pdf(bins, mu, sigma) plt.plot(bins, y, '-') plt.draw() return plt