diff options
Diffstat (limited to 'sampling_alg_lac2020/midi_tests/plot_histogram.py')
-rwxr-xr-x | sampling_alg_lac2020/midi_tests/plot_histogram.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sampling_alg_lac2020/midi_tests/plot_histogram.py b/sampling_alg_lac2020/midi_tests/plot_histogram.py new file mode 100755 index 0000000..ca529b7 --- /dev/null +++ b/sampling_alg_lac2020/midi_tests/plot_histogram.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +import numpy as np +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt +import sys + +if len(sys.argv) != 3: + print("Wrong number of arguments.") + print("USAGE: ./plot_histogram.py <input_file> <output_file>") + quit() + +input_file = sys.argv[1] +output_file = sys.argv[2] + +f = open(input_file) +X = [int(i) for i in f.readlines()] + +# the histogram of the data +n, bins, patches = plt.hist(X, max(X)-min(X), facecolor='green') + +# add a 'best fit' line +# y = mlab.normpdf( bins, mu, sigma) +# l = plt.plot(bins, y, 'r--', linewidth=1) + +plt.xlabel('Sample Index') +plt.ylabel('Number of Selections') +# plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') +# plt.axis([40, 160, 0, 0.03]) +plt.xlim(0,97) +plt.grid(True) + +plt.savefig(output_file) |