Option to have stats on graph or not
This commit is contained in:
26
infocalc.py
26
infocalc.py
@@ -44,7 +44,7 @@ parser.add_argument('--normalizey', action="store_true",
|
|||||||
help='Set y-axis to normalized probability density')
|
help='Set y-axis to normalized probability density')
|
||||||
parser.add_argument('--log', default="INFO",
|
parser.add_argument('--log', default="INFO",
|
||||||
help='Console log level: Number or DEBUG, INFO, WARNING, ERROR')
|
help='Console log level: Number or DEBUG, INFO, WARNING, ERROR')
|
||||||
parser.add_argument('--graphinfo',
|
parser.add_argument('--graphinfo', action="store_true",
|
||||||
help='Put information on the PDF graph')
|
help='Put information on the PDF graph')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@@ -103,18 +103,20 @@ info = -np.emath.log2(prob)
|
|||||||
#print("information content: %f bits", info)
|
#print("information content: %f bits", info)
|
||||||
## place text on plot: https://matplotlib.org/3.3.4/gallery/recipes/placing_text_boxes.html
|
## place text on plot: https://matplotlib.org/3.3.4/gallery/recipes/placing_text_boxes.html
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
textstr = '\n'.join((
|
|
||||||
r'$n=%d$' % (samplesize),
|
|
||||||
r'$\mu=%.2f$' % (mean, ),
|
|
||||||
r'$\sigma=%.2f$' % (stddev, ),
|
|
||||||
r'$P=%.2f$' % (prob, ),
|
|
||||||
r'$I=%.2f$ bits' % (info, )))
|
|
||||||
# these are matplotlib.patch.Patch properties
|
|
||||||
props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
|
|
||||||
|
|
||||||
# place a text box in upper left in axes coords
|
if args.graphinfo:#put info on corner of graph
|
||||||
ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=14,
|
textstr = '\n'.join((
|
||||||
verticalalignment='top', bbox=props)
|
r'$n=%d$' % (samplesize),
|
||||||
|
r'$\mu=%.2f$' % (mean, ),
|
||||||
|
r'$\sigma=%.2f$' % (stddev, ),
|
||||||
|
r'$P=%.2f$' % (prob, ),
|
||||||
|
r'$I=%.2f$ bits' % (info, )))
|
||||||
|
# these are matplotlib.patch.Patch properties
|
||||||
|
props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
|
||||||
|
|
||||||
|
# place a text box in upper left in axes coords
|
||||||
|
ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=14,
|
||||||
|
verticalalignment='top', bbox=props)
|
||||||
|
|
||||||
x = np.linspace(mean-3*stddev, mean+3*stddev, 500)
|
x = np.linspace(mean-3*stddev, mean+3*stddev, 500)
|
||||||
y = norm.pdf(x, loc=mean, scale=stddev)
|
y = norm.pdf(x, loc=mean, scale=stddev)
|
||||||
|
|||||||
2
tests.sh
2
tests.sh
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo "Loading data from file"
|
echo "Loading data from file"
|
||||||
./infocalc.py DATA testdata.csv data1 0.9 1.1
|
./infocalc.py DATA testdata.csv data1 0.9 1.1 --graphinfo
|
||||||
echo "Creating simulated curve from parameters"
|
echo "Creating simulated curve from parameters"
|
||||||
./infocalc.py SIM 8 1.0 0.5 0.9 1.1
|
./infocalc.py SIM 8 1.0 0.5 0.9 1.1
|
||||||
|
|||||||
Reference in New Issue
Block a user