Compare commits

...

2 Commits

Author SHA1 Message Date
0887a9effa cleanup 2026-03-11 20:23:07 +00:00
16327adb58 Studnet t-distribution is more accurate small samples 2026-03-11 20:20:32 +00:00

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
@@ -96,25 +97,23 @@ if args.mode == "DATA":
data = np.array(pd.read_csv(inpath)[args.column]) data = np.array(pd.read_csv(inpath)[args.column])
mean = data.mean() mean = data.mean()
stddev = data.std(ddof=1) stddev = data.std(ddof=1)
# Delta Degrees of Freedom: ddof=0 for population, ddof=1 for sample std dev
samplesize = len(data) samplesize = len(data)
elif args.mode == "SIM": 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
# 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!!!!
#print("probability: %f", prob) #print("probability: %f", prob)
info = -np.emath.log2(prob) info = -np.emath.log2(prob)
#print("information content: %f bits", info) #print("information content: %f bits", info)