Skip to content

Commit

Permalink
use empty input for identitysigma
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamaleldin Elsayed authored and Gamaleldin Elsayed committed Sep 8, 2017
1 parent f04ab64 commit a72525e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 5 additions & 4 deletions demo.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
startup
rng('shuffle', 'twister') % randomize the seed

surrogate_type = 'surrogate-TNC';
surrogate_type = 'surrogate-T';
% this data is a preprocessed version of the data available online from
% http://stat.columbia.edu/~cunningham/pdf/ChurchlandNature2012_code.zip
load exampleData.mat
Expand All @@ -23,15 +23,16 @@
numSurrogates = 100;
params = [];


if strcmp(surrogate_type, 'surrogate-T')
params.margCov{1} = targetSigmaT;
params.margCov{2} = eye(size(dataTensor,2))*(trace(targetSigmaT)/size(dataTensor,2));
params.margCov{3} = eye(size(dataTensor,3))*(trace(targetSigmaT)/size(dataTensor,3));
params.margCov{2} = [];
params.margCov{3} = [];
params.meanTensor = M.T;
elseif strcmp(surrogate_type, 'surrogate-TN')
params.margCov{1} = targetSigmaT;
params.margCov{2} = targetSigmaN;
params.margCov{3} = eye(size(dataTensor,3))*(trace(targetSigmaT)/size(dataTensor,3));
params.margCov{3} = [];
params.meanTensor = M.TN;
elseif strcmp(surrogate_type, 'surrogate-TNC')
params.margCov{1} = targetSigmaT;
Expand Down
11 changes: 11 additions & 0 deletions genTME/fitMaxEntropy.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,19 @@
eigVectors = cell(tensorSize, 1); % eigenVectors of each of the specified marginal covariances
eigValues = cell(tensorSize, 1); % eigenValues of each of the specified marginal covariances
trSigma = nan(tensorSize, 1); % sum of each of the eigenValues of each of the specified marginal covariances
dim = size(maxEntropy.meanTensor);
for i = 1:tensorSize
if ~isempty(margCov{i})
Tr = trace(margCov{i});
break
end
end

for i = 1:tensorSize % load all the inputs
Sigma = margCov{i};
if isempty(Sigma)
Sigma = eye(dim(i))*(trace(Tr)/dim(i));
end
dim(i) = size(Sigma,1);
[Q, S] = svd(Sigma);
[S, ix] = sort(diag(S), 'descend');
Expand Down

0 comments on commit a72525e

Please sign in to comment.