Studnet t-distribution is more accurate small samples

This commit is contained in:
2026-03-11 20:20:32 +00:00
parent f4711640da
commit 16327adb58

View File

@@ -11,7 +11,8 @@ from pathlib import PurePath##https://docs.python.org/3/library/pathlib.html#mod
import numpy as np import numpy as np
import matplotlib import matplotlib
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from scipy.stats import norm from scipy.stats import norm,t
import scipy.stats
import pandas as pd import pandas as pd
#Main program loop #Main program loop
@@ -101,17 +102,18 @@ elif args.mode == "SIM":
mean = args.mean mean = args.mean
stddev = args.stddev stddev = args.stddev
samplesize = args.samplesize samplesize = args.samplesize
df = samplesize - 1
# time to deal with the bounds # time to deal with the bounds
# Delta Degrees of Freedom: ddof=0 for population, ddof=1 for sample std dev # Delta Degrees of Freedom: ddof=0 for population, ddof=1 for sample std dev
prob = 0 prob = 0
if args.upperbound and args.lowerbound: if args.upperbound and args.lowerbound:
prob = norm.cdf(args.upperbound, mean, stddev) - norm.cdf(args.lowerbound, mean, stddev) prob = t.cdf(df,args.upperbound, mean, stddev) - t.cdf(df,args.lowerbound, mean, stddev)
elif args.upperbound: elif args.upperbound:
prob = norm.cdf(args.upperbound, mean, stddev) prob = t.cdf(df,args.upperbound, mean, stddev)
elif args.lowerbound: elif args.lowerbound:
prob = 1 - norm.cdf(args.lowerbound, mean, stddev) prob = 1 - t.cdf(df,args.lowerbound, mean, stddev)
else: else:
prob = 1# no bounds set! prob = 1# no bounds set!
##TODO!!!! ##TODO!!!!