Compare commits

...

4 Commits

3 changed files with 13 additions and 9 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,5 @@
*~ *~
*.log *.log
flycheck_*.py
\#*#
test.pdf

View File

@@ -1,3 +1,5 @@
# ad-calc # ad-calc
Tools to help calculating values for Axiomatic Design analysis Tools to help calculating values for Axiomatic Design analysis
`infocalc.py` calculates information content based upon a csv file or statistical parameters and upper/lower limits

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)