Compare commits
11 Commits
b4c9a4a191
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b4dc59b1d3 | |||
| 1576ec5c9e | |||
| 91766ed8a8 | |||
| c2b5ebb36a | |||
| ff31469da4 | |||
| 43cfba46b3 | |||
| fa7cc6ea4a | |||
| 7efb36b8e5 | |||
| 54c5014faf | |||
| 42d7e30e7d | |||
| f836a53829 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@
|
||||
flycheck_*.py
|
||||
\#*#
|
||||
test.pdf
|
||||
~$*
|
||||
35
infocalc.py
35
infocalc.py
@@ -105,21 +105,18 @@ elif args.mode == "SIM":
|
||||
samplesize = args.samplesize
|
||||
df = samplesize - 1
|
||||
|
||||
prob = 0
|
||||
|
||||
if args.upperbound != None and args.lowerbound != None:
|
||||
prob_upper = 1
|
||||
prob_lower = 0
|
||||
if args.upperbound is not None:
|
||||
prob_upper = t.cdf(df=df,x=args.upperbound, loc=mean, scale=stddev)
|
||||
if args.lowerbound is not None:
|
||||
prob_lower = t.cdf(df=df,x=args.lowerbound, loc=mean, scale=stddev)
|
||||
prob = prob_upper - prob_lower
|
||||
elif args.upperbound != None:
|
||||
prob = t.cdf(df=df,x=args.upperbound, loc=mean, scale=stddev)
|
||||
elif args.lowerbound != None:
|
||||
prob = 1 - t.cdf(df=df,x=args.lowerbound, loc=mean, scale=stddev)
|
||||
else:
|
||||
prob = 1# no bounds set!
|
||||
#print("probability: %f", prob)
|
||||
prob = prob_upper - prob_lower
|
||||
|
||||
info = -np.emath.log2(prob)
|
||||
#print("information content: %f bits", info)
|
||||
logger.info(f"n={samplesize},df={df},mean={mean},stddev={stddev}")
|
||||
logger.info(f"P()={prob},I={info} bits")
|
||||
|
||||
## set default fontsize
|
||||
matplotlib.rcParams['font.size']=args.fontsize
|
||||
## place text on plot: https://matplotlib.org/3.3.4/gallery/recipes/placing_text_boxes.html
|
||||
@@ -148,22 +145,20 @@ y = norm.pdf(x, loc=mean, scale=stddev)
|
||||
if args.normalizey:
|
||||
y = y * stddev#rescale back to unity area
|
||||
plt.axvline(x=mean, color="green", linestyle="dashed", label="mean")
|
||||
if args.lowerbound != None:
|
||||
if args.lowerbound is not None:
|
||||
plt.axvline(args.lowerbound, color="red")
|
||||
if args.upperbound != None:
|
||||
if args.upperbound is not None:
|
||||
plt.axvline(args.upperbound, color="red")
|
||||
|
||||
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')
|
||||
plt.plot(x, y, 'b-', label='T distribution')
|
||||
|
||||
# Filter for which region to fill
|
||||
coloredregion = x#default fill all
|
||||
if args.lowerbound and args.upperbound:
|
||||
if args.lowerbound is not None and args.upperbound is not None:
|
||||
coloredregion = (x >= args.lowerbound) & ( x <= args.upperbound )
|
||||
elif args.upperbound:
|
||||
elif args.upperbound is not None:
|
||||
coloredregion = x <= args.upperbound
|
||||
elif args.lowerbound:
|
||||
elif args.lowerbound is not None:
|
||||
coloredregion = x >= args.lowerbound
|
||||
|
||||
plt.fill_between(x, 0, y, where=coloredregion, color="grey", alpha=0.5, label="Design range",)
|
||||
|
||||
2
tests.sh
2
tests.sh
@@ -3,4 +3,4 @@
|
||||
echo "Loading data from file"
|
||||
./infocalc.py --lowerbound 0.9 --upperbound 1.1 --graphinfo DATA testdata.csv data1
|
||||
echo "Creating simulated curve from parameters"
|
||||
./infocalc.py --lowerbound 0.1 --upperbound 1.5 SIM 8 1.0 0.5
|
||||
./infocalc.py --lowerbound 0.0 --upperbound 1.5 SIM 8 1.0 0.5
|
||||
|
||||
BIN
toy example/ASM-rocket-launcher-angled.PNG
Normal file
BIN
toy example/ASM-rocket-launcher-angled.PNG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 505 KiB |
BIN
toy example/ASM-rocket-launcher-xsec.PNG
Normal file
BIN
toy example/ASM-rocket-launcher-xsec.PNG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 406 KiB |
BIN
toy example/ASM-rocket-launcher.SLDASM
Normal file
BIN
toy example/ASM-rocket-launcher.SLDASM
Normal file
Binary file not shown.
BIN
toy example/ASM-rocket-launcher.SLDDRW
Normal file
BIN
toy example/ASM-rocket-launcher.SLDDRW
Normal file
Binary file not shown.
BIN
toy example/ASM-rocket-launcher.pdf
Normal file
BIN
toy example/ASM-rocket-launcher.pdf
Normal file
Binary file not shown.
BIN
toy example/barrel.SLDPRT
Normal file
BIN
toy example/barrel.SLDPRT
Normal file
Binary file not shown.
BIN
toy example/launcher-spring.SLDPRT
Normal file
BIN
toy example/launcher-spring.SLDPRT
Normal file
Binary file not shown.
BIN
toy example/piston.SLDPRT
Normal file
BIN
toy example/piston.SLDPRT
Normal file
Binary file not shown.
BIN
toy example/rocket.SLDPRT
Normal file
BIN
toy example/rocket.SLDPRT
Normal file
Binary file not shown.
Reference in New Issue
Block a user