Hi,
I solved my problem by removing components that approach zero. Adding this after line 128:
% remove components that are zero
nk = sum(R,1); % 10.51
idx = find(nk<0.01);
% idx = find(nk<4);
if ~isempty(idx)
R(:,idx) = [];
alpha(:,idx) = [];
kappa(:,idx) = [];
m(:,idx) = [];
v(:,idx) = [];
M(:,:,idx) = [];
%Renormalization
tmp = sum(R,2);
R = bsxfun(@times,R,1./tmp);
logR = log(R);
model.alpha = alpha;
model.kappa = kappa;
model.m = m;
model.v = v;
model.M = M; % Whishart: M = inv(W)
end
also added some noise to the matrix in line 176 as suggested below:
V = chol(Xs*Xs'/nk(i) + diag(ones(1,d)*1e-3)); % add some noise to avoid singular matrix
Hope this helps somebody else to. By the way is there a better way to exchange this information? I would have sent you the updated file, but I couldn't find how to do this here.
Hi,
This is a great help for me. However I also have the problem with multdimensional data.
Here is how to reproduce the error:
I create some dummy data (10 gaussian clusters in 3D)
numClusters = 10;
allClusters = [];
for ii = 1:numClusters
sigmaX = 20;
sigmaY = 20;
sigmaZ = 80;
sigmas = diag([sigmaX sigmaY sigmaZ]);
imageSize = diag([ 1000 1000 20 ]);
simGauss = sigmas * randn(3,2e2);
mu = imageSize * rand(3,1);
cluster = bsxfun(@plus, simGauss,mu);
allClusters = cat(2, allClusters, cluster);
end
label=vbgm(allClusters,20);
Error using chol
Matrix must be positive definite.
Sometimes it works, most of the time not however. I trace the problem to entries of nk becoming zero and a subsequent division by zero.
I have tried to replace the zero values with small ones, but that didn't help. Have no solution so far :-/
Thanks for this! Is there anyway to use it with multi-dimensional data points? It's giving me an error about the matrix not being positive definite.
Thanks.
Comment only