-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_exp.py
More file actions
61 lines (48 loc) · 1.41 KB
/
Copy pathtest_exp.py
File metadata and controls
61 lines (48 loc) · 1.41 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
import experiment
import numpy as np
EPS = 1e-9
def test_eigenvals():
m = experiment.generateRandomMatrix(100, 1, 20, 123)
experiment.checkEigenValues(m, 1, 20)
print('test eigenvals: ok')
# def test_gen():
# G_m = experiment.generateRandomGMatrix(5, 5, -1, 1, 3)
# print(G_m)
# print(experiment.computeLG(G_m))
def test_exp():
G_m = experiment.generateRandomGMatrix(100, 100, -1, 1, 123)
f_m = experiment.generateRandomFHMatrix(100, 1, 3, 123)
h_m = experiment.generateRandomFHMatrix(100, 2, 4, 321)
exp = experiment.calculateQuadraticFormExperimentParams(f_m, G_m, h_m)
print(exp.mu_x)
assert np.abs(exp.mu_x - 1) < EPS
print(exp.L_f)
assert np.abs(exp.L_f - 3) < EPS
print(exp.mu_y)
assert np.abs(exp.mu_y - 2) < EPS
print(exp.L_h)
assert np.abs(exp.L_h - 4) < EPS
print('L_G:', exp.L_G)
print('test exp: ok')
def test_exp2():
exp, _, _, _ = experiment.generateQuadraticFormExperiment(
100, 100,
{'L': 10, 'mu': 2},
{'min': -1, 'max': 1},
{'L': 5, 'mu': 3},
1111
)
print(exp.mu_x)
assert np.abs(exp.mu_x - 2) < EPS
print(exp.L_f)
assert np.abs(exp.L_f - 10) < EPS
print(exp.mu_y)
assert np.abs(exp.mu_y - 3) < EPS
print(exp.L_h)
assert np.abs(exp.L_h - 5) < EPS
print('L_G:', exp.L_G)
print('test exp: ok')
# test_gen()
test_eigenvals()
test_exp()
test_exp2()