-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplot_alpha.py
More file actions
38 lines (29 loc) · 892 Bytes
/
Copy pathplot_alpha.py
File metadata and controls
38 lines (29 loc) · 892 Bytes
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
37
38
import sys
import matplotlib.pyplot as plt
from collections import defaultdict
from itertools import imap
import operator
def dotproduct(vec1, vec2):
"""
"""
return sum(imap(operator.mul, vec1, vec2))
if __name__ == "__main__":
support = defaultdict(list)
with open(sys.argv[1], 'r') as f:
line = f.readline()
while line:
action = int(line)
line = f.readline()
support[action].append(map(float, line.split()))
nl = f.readline()
line = f.readline()
fig, ax = plt.subplots(1)
x = [ (1./20)*ii for ii in range(21) ]
colors = ['blue', 'red', 'yellow', 'black']
i = 0
for key in support.keys():
i += 1
for v in support[key]:
y = map(lambda z: dotproduct([z, 1-z], v),x)
ax.plot(x, y, color=colors[i])
fig.savefig('output.png')