correction testEMGLLF.R
[valse.git] / src / test / OLD_TEST_MATLAB / testConstructionModelesLassoMLE.m
CommitLineData
7b272073
BA
1function[] = testConstructionModelesLassoMLE()
2
3 testFolder = 'data/';
4 delimiter = '\n';
5
6 %get dimensions
7 dimensions = dlmread(strcat(testFolder,'dimensions'), delimiter);
8 n = dimensions(1);
9 p = dimensions(2);
10 m = dimensions(3);
11 k = dimensions(4);
12 L = dimensions(5);
13
14 %get all input arrays
15 phiInit = reshape(dlmread(strcat(testFolder,'phiInit'), delimiter), p, m, k);
16 rhoInit = reshape(dlmread(strcat(testFolder,'rhoInit'), delimiter), m, m, k);
17 piInit = transpose(dlmread(strcat(testFolder,'piInit'), delimiter));
18 gamInit = reshape(dlmread(strcat(testFolder,'gamInit'), delimiter), n, k);
19 mini = int64(dlmread(strcat(testFolder,'mini'), delimiter));
20 maxi = int64(dlmread(strcat(testFolder,'maxi'), delimiter));
21 gamma = dlmread(strcat(testFolder,'gamma'), delimiter);
22 glambda = dlmread(strcat(testFolder,'glambda'), delimiter);
23 X = reshape(dlmread(strcat(testFolder,'X'), delimiter), n, p);
24 Y = reshape(dlmread(strcat(testFolder,'Y'), delimiter), n, m);
25 seuil = dlmread(strcat(testFolder,'seuil'), delimiter);
26 tau = dlmread(strcat(testFolder,'tau'), delimiter);
27 A1 = int64(reshape(dlmread(strcat(testFolder,'A1'), delimiter), p, m+1, L));
28 A2 = int64(reshape(dlmread(strcat(testFolder,'A2'), delimiter), p, m+1, L));
29
30 %run constructionModelesLassoMLE.m
31 [phi,rho,pi,lvraisemblance] = constructionModelesLassoMLE(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda,X,Y,seuil,tau,A1,A2);
32
33 %get all stored outputs
34 ref_phi = reshape(dlmread(strcat(testFolder,'phi'), delimiter), p, m, k, L);
35 ref_rho = reshape(dlmread(strcat(testFolder,'rho'), delimiter), m, m, k, L);
36 ref_pi = reshape(dlmread(strcat(testFolder,'pi'), delimiter), k, L);
37 ref_lvraisemblance = reshape(dlmread(strcat(testFolder,'lvraisemblance'), delimiter), L, 2);
38
39 %check that output correspond to stored output
40 tol = 1e-5;
41 checkOutput('phi',phi,ref_phi,tol);
42 checkOutput('rho',rho,ref_rho,tol);
43 checkOutput('pi',pi,ref_pi,tol);
44 checkOutput('lvraisemblance',lvraisemblance,ref_lvraisemblance,tol);
45
46end