-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
77 lines (64 loc) · 2.06 KB
/
test.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
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
75
76
77
from jl import *
import numpy as np
from matplotlib import pyplot as plt
import time
def distovereps():
eps = np.linspace(0.5,0,10,endpoint=False)
minerr=[1.0]
maxerr=[1.0]
meanerr=[1.0]
for e in eps[::-1]:
print(e)
[subspaceDim, data] = get_hyperparams(1000, 4096, e, 'gaussian','dense')
trans = jl(data,subspaceDim,'gaussian')
err = checkTheoremSingle(data,trans,e)
minerr.append(np.min(err))
maxerr.append(np.max(err))
meanerr.append(np.mean(err))
eps = np.append(eps,[0.0])
plt.plot(eps[::-1], minerr)
plt.plot(eps[::-1], maxerr)
plt.plot(eps[::-1], meanerr)
plt.title('Single distortions')
plt.legend(['min err','max err','mean err'], loc='upper left')
plt.xlabel('$\epsilon$')
plt.ylabel('Distortion')
plt.show()
def stabsparse():
qlist = np.linspace(3,200,50)
minerr = []
maxerr = []
meanerr = []
for q in qlist:
print(q)
[subspaceDim, data] = get_hyperparams(1000, 4096, 0.25, 'sparse','dense')
trans = jl(data,subspaceDim,'sparse',q)
err = checkTheoremSingle(data,trans,0.25)
minerr.append(np.min(err))
maxerr.append(np.max(err))
meanerr.append(np.mean(err))
plt.plot(qlist, minerr)
plt.plot(qlist, maxerr)
plt.plot(qlist, meanerr)
plt.title('Dense data')
plt.legend(['min err','max err','mean err'], loc='upper left')
plt.xlabel('q')
plt.ylabel('Distortion')
plt.show()
def timecompare():
datatype="dense"
nlist = np.logspace(1,6,6)
methods = ['gaussian','sparse','circulant','hadamard']
timeval={m:[] for m in methods}
for m in methods:
print(m)
for size in nlist:
[subspaceDim, data] = get_hyperparams(int(size), 4096, 0.25, m,datatype)
start = time.time()
trans = jl(data, subspaceDim, m, 3.0)
diff = time.time() - start
timeval[m].append(diff)
return [nlist, timeval]
if __name__ == "__main__":
stabsparse()
#distovereps()