From 99b372aebd8b00775c40b16c512d9e59394a8c14 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Sat, 14 Jan 2017 13:30:44 +0100 Subject: [PATCH] write generateRunSaveTest_EMGLLF.R --- .../generateRunSaveTest_EMGLLF.R | 33 +++++++++++++ .../generateRunSaveTest_EMGLLF.m | 47 ------------------- 2 files changed, 33 insertions(+), 47 deletions(-) create mode 100644 src/test/generate_test_data/generateRunSaveTest_EMGLLF.R delete mode 100644 src/test/generate_test_data/generateRunSaveTest_EMGLLF.m diff --git a/src/test/generate_test_data/generateRunSaveTest_EMGLLF.R b/src/test/generate_test_data/generateRunSaveTest_EMGLLF.R new file mode 100644 index 0000000..60ac6c5 --- /dev/null +++ b/src/test/generate_test_data/generateRunSaveTest_EMGLLF.R @@ -0,0 +1,33 @@ +generateRunSaveTest_EMGLLF = function(n=200, p=15, m=10, k=3, mini=5, maxi=10, + gamma=1., lambda=0.5, tau=1e-6) +{ + testFolder = "data/" + dir.create(testFolder, showWarnings=FALSE, mode="0755") + delimiter = " " + + #save inputs + params = basicInitParameters(n, p, m, k) + io = generateIOdefault(n, p, m, k) + write.table(paste(testFolder,"phiInit",sep=""), params$phiInit, sep=delimiter); + write.table(paste(testFolder,"rhoInit",sep=""), params$rhoInit, sep=delimiter); + write.table(paste(testFolder,"piInit",sep=""), params$piInit, sep=delimiter); + write.table(paste(testFolder,"gamInit",sep=""), params$gamInit, sep=delimiter); + write.table(paste(testFolder,"mini",sep=""), mini, sep=delimiter); + write.table(paste(testFolder,"maxi",sep=""), maxi, sep=delimiter); + write.table(paste(testFolder,"gamma",sep=""), gamma, sep=delimiter); + write.table(paste(testFolder,"lambda",sep=""), lambda, sep=delimiter); + write.table(paste(testFolder,"X",sep=""), io$X, sep=delimiter); + write.table(paste(testFolder,"Y",sep=""), io$Y, sep=delimiter); + write.table(paste(testFolder,"tau",sep=""), tau, sep=delimiter); + write.table(paste(testFolder,"dimensions",sep=""), c(n,p,m,k), sep=delimiter); + + res = EMGLLF(params$phiInit,params$rhoInit,params$piInit,params$gamInit,mini,maxi, + gamma,lambda,io$X,io$Y,tau); + + #save outputs + write.table(paste(testFolder,"phi",sep=""), res$phi, sep=delimiter); + write.table(paste(testFolder,"rho",sep=""), res$rho, sep=delimiter); + write.table(paste(testFolder,"pi",sep=""), res$pi, sep=delimiter); + write.table(paste(testFolder,"LLF",sep=""), res$LLF, sep=delimiter); + write.table(paste(testFolder,"S",sep=""), res$S, sep=delimiter); +} diff --git a/src/test/generate_test_data/generateRunSaveTest_EMGLLF.m b/src/test/generate_test_data/generateRunSaveTest_EMGLLF.m deleted file mode 100644 index b668a57..0000000 --- a/src/test/generate_test_data/generateRunSaveTest_EMGLLF.m +++ /dev/null @@ -1,47 +0,0 @@ -function[] = generateRunSaveTest_EMGLLF(n, p, m, k, mini, maxi, gamma, lambda, varargin) - - %set defaults for optional inputs - optargs = {200 15 10 3 5 10 1.0 0.5}; - %replace defaults by user parameters - optargs(1:length(varargin)) = varargin; - [n, p, m, k, mini, maxi, gamma, lambda] = optargs{:}; - tau = 1e-6; - mini = int64(mini); - maxi = int64(maxi); - - %Generate phiInit,piInit,... - [phiInit,rhoInit,piInit,gamInit] = basicInitParameters(n, p, m, k); - - %Generate X and Y - [X, Y, ~] = generateIOdefault(n, p, m, k); - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - testFolder = 'data/'; - mkdir(testFolder); - delimiter = ' '; - - %save inputs - dlmwrite(strcat(testFolder,'phiInit'), reshape(phiInit,1,[]), delimiter); - dlmwrite(strcat(testFolder,'rhoInit'), reshape(rhoInit,1,[]), delimiter); - dlmwrite(strcat(testFolder,'piInit'), piInit, delimiter); - dlmwrite(strcat(testFolder,'gamInit'), reshape(gamInit,1,[]), delimiter); - dlmwrite(strcat(testFolder,'mini'), mini, delimiter); - dlmwrite(strcat(testFolder,'maxi'), maxi, delimiter); - dlmwrite(strcat(testFolder,'gamma'), gamma, delimiter); - dlmwrite(strcat(testFolder,'lambda'), lambda, delimiter); - dlmwrite(strcat(testFolder,'X'), reshape(X,1,[]), delimiter); - dlmwrite(strcat(testFolder,'Y'), reshape(Y,1,[]), delimiter); - dlmwrite(strcat(testFolder,'tau'), tau, delimiter); - dlmwrite(strcat(testFolder,'dimensions'), [n,p,m,k], delimiter); - - [phi,rho,pi,LLF,S] = EMGLLF(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau); - - %save output - dlmwrite(strcat(testFolder,'phi'), reshape(phi,1,[]), delimiter); - dlmwrite(strcat(testFolder,'rho'), reshape(rho,1,[]), delimiter); - dlmwrite(strcat(testFolder,'pi'), pi, delimiter); - dlmwrite(strcat(testFolder,'LLF'), LLF, delimiter); - dlmwrite(strcat(testFolder,'S'), reshape(S,1,[]), delimiter); - -end -- 2.44.0