-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_best_postrun.py
More file actions
45 lines (33 loc) · 1 KB
/
Copy pathplot_best_postrun.py
File metadata and controls
45 lines (33 loc) · 1 KB
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
39
40
41
42
43
44
45
from scitools.std import *
def plot_last_thingie(f):
infile = open('out.dat', 'r')
values = []
x = []
all_data = []
for line in infile:
if line.startswith("newfunc"):
all_data.append([x, values])
x = []
values = []
else:
split = line.split()
x.append(float(split[0]))
values.append(float(split[1]))
for x, values in all_data:
x = array(x)
values = array(values)
fx = f(x);
figure(1)
plot(x, fx, 'b', show=False)
axis([min(x)*1.2, max(x)*1.2, min(fx)*1.2, max(fx)*1.2])
hold("on")
plot(x, values, 'g', show=True)
hold("off")
exact = fx
match_factor = 0;
for trueval, testval in zip(exact, values):
match_factor += (trueval - testval)*(trueval - testval);
print "Error: ", sqrt(match_factor)
raw_input("Press a key")
f = lambda x:x*x*exp(-x*x)
plot_last_thingie(f)