-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathData_Generation_X.py
74 lines (50 loc) · 1.91 KB
/
Data_Generation_X.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
# Necessary Packages
import numpy as np
#%% AR(1) Generation.
'''
X_t = coef * X_t-1 + n
n ~ N(0, sigma^2)
sigma = np.sqrt(margin*(1-coef*coef))
Therefore, Marginal distribution is N(0, margin)
Inputs
- n: Number of samples
- p: Number of features
- phi: Autoregressiveness
- margin: Std of the normal distribution
'''
def AR_Gauss_X1 (n, d, t, phi, sigma):
# Initialization
Output_X = list()
# For each sample
for i in range(n):
Temp_Output_X = np.zeros([t,d])
# For each feature
for j in range(d):
for k in range(t):
# Starting feature
if (k == 0):
Temp_Output_X[k,j] = np.random.normal(0,sigma)
# AR(1) Generation
else:
Temp_Output_X[k,j] = phi[j] * Temp_Output_X[k-1,j] + (1-phi[j])*np.random.normal(0,sigma)
Output_X.append(Temp_Output_X)
return Output_X
#%%
def AR_Gauss_X2 (n, d, t, phi, sigma, gamma):
# Initialization
Output_X = list()
# For each sample
for i in range(n):
Temp_Output_X = np.zeros([t,2*d])
# For each feature
for j in range(d):
for k in range(t):
# Starting feature
if (k == 0):
Temp_Output_X[k,j] = np.random.normal(0,sigma)
# AR(1) Generation
else:
Temp_Output_X[k,j] = phi[j] * Temp_Output_X[k-1,j] + (1-phi[j])*np.random.normal(0,sigma)
Temp_Output_X[k,d+j] = Temp_Output_X[k,j] + np.random.normal(0,gamma)
Output_X.append(Temp_Output_X)
return Output_X