Studnet t-distribution is more accurate small samples
This commit is contained in:
10
infocalc.py
10
infocalc.py
@@ -11,7 +11,8 @@ from pathlib import PurePath##https://docs.python.org/3/library/pathlib.html#mod
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
from scipy.stats import norm
|
||||
from scipy.stats import norm,t
|
||||
import scipy.stats
|
||||
import pandas as pd
|
||||
|
||||
#Main program loop
|
||||
@@ -101,17 +102,18 @@ elif args.mode == "SIM":
|
||||
mean = args.mean
|
||||
stddev = args.stddev
|
||||
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
|
||||
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:
|
||||
prob = norm.cdf(args.upperbound, mean, stddev)
|
||||
prob = t.cdf(df,args.upperbound, mean, stddev)
|
||||
elif args.lowerbound:
|
||||
prob = 1 - norm.cdf(args.lowerbound, mean, stddev)
|
||||
prob = 1 - t.cdf(df,args.lowerbound, mean, stddev)
|
||||
else:
|
||||
prob = 1# no bounds set!
|
||||
##TODO!!!!
|
||||
|
||||
Reference in New Issue
Block a user