-
Notifications
You must be signed in to change notification settings - Fork 1
/
graph-entro.py
36 lines (32 loc) · 895 Bytes
/
graph-entro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python2.5
#
# Plot probability distribution generated by entro.py
# Kornilios Kourtis <[email protected]>
#
import Gnuplot as G
from random import randint, sample
from entro import e2pd_initial_pd, entropy2pd
import sys
def rand_graph(entropy, fname, graphs_nr=40):
en = entropy
_g = G.Gnuplot()
print 'Entropy', en
_g("set logscale y")
_g("set style data linespoints")
_g('set terminal png size 640 480')
_initial = ("min", "max")
pd = []
for i in xrange(graphs_nr):
print i, " ",
sys.stdout.flush()
pdi = e2pd_initial_pd(256,shuffle=randint(0,256*2),initial=sample(_initial, 1)[0])
pd.append(G.Data(entropy2pd(en, 256, pdi)))
print
_g("set output \'%s\'" % fname)
_g.plot(*pd)
if __name__ == '__main__':
from sys import argv, exit
if len(argv) < 3:
print "Usage: %s <entropy> <fname> " % argv[0]
exit(1)
rand_graph(float(argv[1]), argv[2])