From 8cc359e074c7a46b5ed065c3685810f65757f4cf Mon Sep 17 00:00:00 2001
From: emilie <emilie@devijver.org>
Date: Sat, 18 Mar 2017 17:11:50 +0100
Subject: [PATCH] unneccessary changes

---
 reports/simulData_17mars.R       |  4 ++--
 test/generate_test_data/EMGLLF.R | 13 +++++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/reports/simulData_17mars.R b/reports/simulData_17mars.R
index cdb476c..252e660 100644
--- a/reports/simulData_17mars.R
+++ b/reports/simulData_17mars.R
@@ -5,10 +5,10 @@ simulData_17mars = function(ite){
   ## Modele
   ###########
   K = 2
-  p = 48
+  p = 20
   T = seq(0,1.5,length.out = p)
   T2 = seq(0,3, length.out = 2*p)
-  n = 100
+  n = 30
   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
   sigmaX = 0.12
   sigmaY = 0.12
diff --git a/test/generate_test_data/EMGLLF.R b/test/generate_test_data/EMGLLF.R
index fc3220f..272eb6f 100644
--- a/test/generate_test_data/EMGLLF.R
+++ b/test/generate_test_data/EMGLLF.R
@@ -1,4 +1,4 @@
-EMGLLF_R = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau)
+EMGLLF = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau)
 {
   #matrix dimensions
   n = dim(X)[1]
@@ -30,7 +30,7 @@ EMGLLF_R = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,ta
   Gam = matrix(0, n,k)
   EPS = 1E-15
   
-  while(ite <= mini || (ite <= maxi && (dist >= tau || dist2 >= sqrt(tau))))
+  while(ite <= mini || (ite<= maxi && (dist>= tau || dist2 >= sqrt(tau))))
 	{
     Phi = phi
     Rho = rho
@@ -72,6 +72,7 @@ EMGLLF_R = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,ta
       kk = kk+1
     }
 
+#if (ite==2) browser()
     #t[m] la plus grande valeur dans la grille O.1^k tel que ce soit décroissante ou constante
     while( kk < 1000 && -a/n + lambda * sum(pi^gamma * b) <
 			-sum(gam2 * log(pi2))/n + lambda * sum(pi2^gamma * b) )
@@ -102,7 +103,9 @@ EMGLLF_R = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,ta
 			{
         for (mm in 1:m)
 				{
-          S[j,mm,r] = -rho[mm,mm,r]*ps2[j,mm,r] + sum(phi[-j,mm,r] * Gram2[j, setdiff(1:p,j),r])
+          S[j,mm,r] = -rho[mm,mm,r]*ps2[j,mm,r] + sum(phi[-j,mm,r] * Gram2[j, setdiff(1:p, j),r])
+#						(if(j>1) sum(phi[1:(j-1),mm,r] * Gram2[j,1:(j-1),r]) else 0) +
+#						(if(j<p) sum(phi[(j+1):p,mm,r] * Gram2[j,(j+1):p,r]) else 0)
           if (abs(S[j,mm,r]) <= n*lambda*(pi[r]^gamma))
             phi[j,mm,r]=0
           else if(S[j,mm,r] > n*lambda*(pi[r]^gamma))
@@ -128,7 +131,9 @@ EMGLLF_R = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,ta
       sumLLF1 = 0.0;
       for (r in 1:k)
 			{
-				Gam[i,r] = pi[r] * exp(-0.5*sqNorm2[r]) #* det(rho[,,r]) #FIXME: still issues here ?!?!
+				#FIXME: numerical problems, because 0 < det(Rho[,,r] < EPS; what to do ?!
+        #       consequence: error in while() at line 77
+				Gam[i,r] = pi[r] * exp(-0.5*sqNorm2[r])* det(rho[,,r])
         sumLLF1 = sumLLF1 + Gam[i,r] / (2*base::pi)^(m/2)
       }
       sumLogLLF2 = sumLogLLF2 + log(sumLLF1)
-- 
2.44.0