From 49fb7ed3fbbb6f7537af8a65d917fa0550006cdf Mon Sep 17 00:00:00 2001 From: Joseph Timothy Foley Date: Fri, 12 Dec 2025 13:30:56 +0000 Subject: [PATCH] student distribution option --- normdist.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/normdist.py b/normdist.py index db0dd72..f59a256 100644 --- a/normdist.py +++ b/normdist.py @@ -2,19 +2,22 @@ # From https://www.geeksforgeeks.org/python/how-to-plot-a-normal-distribution-with-matplotlib-in-python/ import numpy as np import matplotlib.pyplot as plt -from scipy.stats import norm +import scipy.stats data = np.array([1, 1.1, 0.9, 1, 1, 0.9, 0.9]) lowerbound = 0.9 upperbound = 1.0 mean = data.mean() -stddev = data.std() +stddev = data.std(ddof=1) +# Delta Degrees of Freedom: ddof=0 for population, ddof=1 for sample std dev x = np.linspace(mean-3*stddev, mean+3*stddev, 1000) -y = norm.pdf(x, mean, stddev) +y = scipy.stats.norm.pdf(x, mean, stddev) plt.plot(x, y, 'b-', label='Normal Distribution') +#yt = scipy.stats.t.pdf(x, len(data)-1, mean, stddev) +#plt.plot(x, yt, 'g-', label='T Distribution') coloredregion = (x >= lowerbound) & ( x <= upperbound ) #select x values -plt.vlines([lowerbound, upperbound], 0, plt.ylim()[1])#ylim returns [bot, top] +plt.vlines([lowerbound, upperbound], 0, plt.ylim()[1], color="red")#ylim returns [bot, top] plt.fill_between(x, 0, y, where=coloredregion, color="grey", alpha=0.5, label="Design Range") plt.xlabel('X')