-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_synthetic_data.py
37 lines (29 loc) · 1.17 KB
/
generate_synthetic_data.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
import numpy as np
packet_delimiter = '|'
value_delimiter = '_'
def get_sample_points():
return np.random.choice(np.arange(-10, 11), 10)
def sigmoid(x, shift, coeff):
return 1 / (1 + np.exp(-coeff*(x - shift)))
def generate_synthetic_data():
return packet_delimiter.join([get_thumb_value(), get_index_value(), get_middle_value(), get_ring_value()])
def get_thumb_value():
return np.array2string(sigmoid(get_sample_points(), 0, 2) * 200,
separator='_',
formatter={'float_kind':lambda x: "%.2f" % x},
suppress_small = True)[1:-1]
def get_index_value():
return np.array2string(sigmoid(get_sample_points(), 0, 1) * 1500,
separator='_',
formatter={'float_kind':lambda x: "%.2f" % x},
suppress_small = True)[1:-1]
def get_middle_value():
return np.array2string(sigmoid(get_sample_points(), 0, 0.8) * 3000,
separator='_',
formatter={'float_kind':lambda x: "%.2f" % x},
suppress_small = True)[1:-1]
def get_ring_value():
return np.array2string(sigmoid(get_sample_points(), 0, 1.5) * 500,
separator='_',
formatter={'float_kind':lambda x: "%.2f" % x},
suppress_small = True)[1:-1]