unneccessary changes
[valse.git] / reports / simulData_17mars.R
1 simulData_17mars = function(ite){
2 set.seed = 22021989+ite
3
4 ###########
5 ## Modele
6 ###########
7 K = 2
8 p = 20
9 T = seq(0,1.5,length.out = p)
10 T2 = seq(0,3, length.out = 2*p)
11 n = 30
12 x1 = cos(2*base::pi*T) + 0.2*cos(4*2*base::pi*T) + 0.3*c(rep(0,round(length(T)/7)),rep(1,round(length(T)*(1-1/7))))+1
13 sigmaX = 0.12
14 sigmaY = 0.12
15 beta = list()
16 p1= 0.5
17 beta[[1]] =diag(c(rep(p1,5),rep(1,5), rep(p1,5), rep(1, p-15)))
18 p2 = 1
19 beta[[2]] = diag(c(rep(p2,5),rep(1,5), rep(p2,5), rep(1, p-15)))
20 ARI1 = ARI2 = ARI3 = 0
21
22 ###########
23 ## Data + Projection
24 ###########
25 require(wavelets)
26 XY = array(0, dim = c(2*p,n))
27 Xproj = array(0, dim=c(48,n))
28 Yproj = array(0, dim=c(48,n))
29 XYproj = array(0, dim=c(96,n))
30 x = x1 + matrix(rnorm(n*p, 0, sigmaX), ncol = n)
31 affec = sample(c(1,2), n, replace = TRUE)
32 y = x
33 xy = matrix(0,ncol=n, nrow= 2*p)
34 for (i in c(1:n)){
35 y[,i] = x[,i] %*% beta[[affec[i]]] + rnorm(p, 0, sigmaY)
36 xy[,i] = c(x[,i],y[,i])
37 XY[,i] = xy[,i] - mean(xy[,i])
38 Dx = dwt(x[,i], filter='haar')@W
39 Dx = rev(unlist(Dx))
40 Dx = Dx[2:(1+3+6+12+24)]
41 Ax = dwt(x[,i], filter='haar')@V
42 Ax = rev(unlist(Ax))
43 Ax = Ax[2:(1+3)]
44 Dy = dwt(y[,i], filter='haar')@W
45 Dy = rev(unlist(Dy))
46 Dy = Dy[2:(1+3+6+12+24)]
47 Ay = dwt(y[,i], filter='haar')@V
48 Ay = rev(unlist(Ay))
49 Ay = Ay[2:(1+3)]
50 Xproj[,i] = c(Ax,Dx)
51 Yproj[,i] = c(Ay,Dy)
52 XYproj[,i] = c(Ax,Dx,Ay,Dy)
53 }
54
55 res_valse = valse(x,y)
56 res_valse_proj = valse(Xproj, Yproj)
57
58 save(res_valse,file=paste("./Out/Res_",ite, ".RData",sep=""))
59 save(res_valse_proj,file=paste("./Out/ResProj_",ite, ".RData",sep=""))
60 }