-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrandom.py
More file actions
74 lines (55 loc) · 2.06 KB
/
random.py
File metadata and controls
74 lines (55 loc) · 2.06 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 29 06:37:35 2019
@author: Andrej Leban
"""
import numpy as np
import pandas as pd
import scipy as sp
import matplotlib.pyplot as plt
import csv
# the data is generated by enabling the macro DUMPINTERMEDIATE in CMake
# intermediate dists
a = np.array(list(map(float, list(csv.reader(open("uniforms")))[0])))
plt.hist(a, bins=10, density=True)
plt.figure()
b = np.array(list(map(float, list(csv.reader(open("gaussians")))[0])))
b[b == -np.inf] = -np.finfo(float).max
b[b == np.inf] = np.finfo(float).max
bhist = b[b > -1000]
bhist = bhist[bhist < 1000]
plt.hist(bhist, bins=1000, density=True)
# convergence
with open("PM", 'r') as file:
pm = np.array([list(map(float, row)) for row in
list(csv.reader(file, delimiter=' '))])
with open("PM-AT", 'r') as file:
pmat = np.array([list(map(float, row)) for row in
list(csv.reader(file, delimiter=' '))])
with open("MT", 'r') as file:
mt = np.array([list(map(float, row)) for row in
list(csv.reader(file, delimiter=' '))])
with open("MT-AT", 'r') as file:
mtat = np.array([list(map(float, row)) for row in
list(csv.reader(file, delimiter=' '))])
plt.figure()
plt.plot(pm[:, 0], pm[:, 1], pmat[:, 0], pmat[:, 1],
mt[:, 0], mt[:, 1], mtat[:, 0], mtat[:, 1])
plt.ylim(0, 200)
plt.xscale('log')
plt.legend(["pm", "pm-at", "mt", "mt-at"])
# convergence - residuals
plt.figure()
plt.plot(pm[:, 0], np.abs(pm[-1, 1] - pm[:, 1]),
pmat[:, 0], np.abs(pmat[-1, 1] - pmat[:, 1]),
mt[:, 0], np.abs(mt[-1, 1] - mt[:, 1]),
mtat[:, 0], np.abs(mtat[-1, 1] - mtat[:, 1]))
plt.ylim(0, 200)
plt.xscale('log')
plt.legend(["pm", "pm-at", "mt", "mt-at"])
# metric - integral under the logscale curve
print("Sums of residuals are:")
print(np.sum(np.abs(pm[-1, 1] - pm[:, 1])),
np.sum(np.abs(pmat[-1, 1] - pmat[:, 1])),
np.sum(np.abs(mt[-1, 1] - mt[:, 1])),
np.sum(np.abs(mtat[-1, 1] - mtat[:, 1])))