fix generateRunSave_EMGLLF, simplify arrays readings
[valse.git] / src / test / generate_test_data / generateRunSaveTest_EMGrank.R
1 generateRunSaveTest_EMGrank = function(n=200, p=15, m=10, k=3, mini=5, maxi=10, gamma=1.0, rank = c(1,2,4)){
2 testFolder = "data/"
3 dir.create(testFolder, showWarnings=FALSE, mode="0755")
4 delimiter = " "
5
6 tau = 1e-6
7
8 pi = rep(1.0/k, k)
9 rho = array(0, dim=c(m,m,k))
10
11 for(i in 1:k){
12 rho[,,i] = diag(1,m)
13 }
14
15 #Generate X and Y
16 require(valse)
17 generateIOdef = valse:::generateIOdefault(n, p, m, k)
18
19 #save inputs
20 write.table(paste(testFolder,"rho",sep=""), rho, sep=delimiter)
21 write.table(paste(testFolder,"pi",sep=""), pi, sep=delimiter)
22 write.table(paste(testFolder,"mini",sep=""), mini, sep=delimiter)
23 write.table(paste(testFolder,"maxi",sep=""), maxi, sep=delimiter)
24 write.table(paste(testFolder,"X",sep=""), generateIOdef$X sep=delimiter)
25 write.table(paste(testFolder,"Y",sep=""), generateIOdef$Y, sep=delimiter)
26 write.table(paste(testFolder,"tau",sep=""), tau, sep=delimiter)
27 write.table(paste(testFolder,"rank",sep=""), rank, sep=delimiter)
28 write.table(paste(testFolder,"dimensions",sep=""), c(n,p,m,k), sep=delimiter)
29
30 EMG_rank = EMG(pi,rho,mini,maxi,X,Y,tau,rank)
31
32 #save output
33 write.table(paste(testFolder,"phi",sep=""), EMG_rank$phi, sep=delimiter)
34 write.table(paste(testFolder,"LLF",sep=""), EMG_rank$LLF, sep=delimiter)
35 }