-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeupdata.py
42 lines (31 loc) · 1.01 KB
/
makeupdata.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
__author__ = 'scip'
import numpy as np
import matplotlib.pyplot as plt
number_of_data_sets = 100
number_of_atoms = 80
data_length = 30
def make_sin_vec():
start = -abs(np.random.rand() * np.random.randint(6, 15))
stop = abs(np.random.rand() * np.random.randint(6, 150))
x = np.linspace(start, stop, data_length)
wave = np.sin(x).reshape(data_length, 1)
return wave * np.random.rand()
representation = np.zeros([number_of_atoms, number_of_data_sets])
for j in range(number_of_data_sets):
n = np.random.randint(1, number_of_atoms / 2)
for _ in range(n):
i = np.random.randint(0, number_of_atoms)
representation[i, j] = np.random.rand()
columns = []
for _ in range(number_of_atoms):
columns.append(make_sin_vec())
dictionary = np.hstack(columns)
dictionary /= np.linalg.norm(dictionary)
data = np.dot(dictionary, representation)
if __name__ == '__main__':
print dictionary.shape
print data.shape
plt.plot(data)
plt.show()
plt.plot(dictionary)
plt.show()