-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatistical_learning_utils.py
More file actions
50 lines (48 loc) · 1.04 KB
/
statistical_learning_utils.py
File metadata and controls
50 lines (48 loc) · 1.04 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
import random
# Transition structure copied from Durrant et al. (2011):
transition_structure = {
(1,1): 4,
(1,2): 3,
(1,3): 2,
(1,4): 1,
(1,5): 5,
(2,1): 5,
(2,2): 4,
(2,3): 3,
(2,4): 2,
(2,5): 1,
(3,1): 3,
(3,2): 2,
(3,3): 1,
(3,4): 5,
(3,5): 4,
(4,1): 1,
(4,2): 5,
(4,3): 4,
(4,4): 3,
(4,5): 2,
(5,1): 2,
(5,2): 1,
(5,3): 5,
(5,4): 4,
(5,5): 3
}
def get_sequence():
start = [random.randint(1,5),random.randint(1,5)]
for i in range(50):
num = random.uniform(0, 1)
if num > 0.1:
next_val = transition_structure[tuple(start[-2:])]
else:
if 0 < num < 0.02:
next_val = 1
if 0.02 < num < 0.04:
next_val = 2
if 0.04 < num < 0.06:
next_val = 3
if 0.06 < num < 0.08:
next_val = 4
if 0.08 < num < 0.1:
next_val = 5
start.append(next_val)
return ','.join([str(i) for i in start])