From: Rafael L. <ra...@la...> - 2012-11-25 13:54:59
|
The function cov2ellipse in the geometry package is not computing the ellipse axes correctly. The first problem is that the scale of the axes is wrong. This can be demonstrated with the code below ###################################################################### function cov2ellipse_demo (K) L = chol(K,'lower'); u = randn(1e3,2)*L'; elli = cov2ellipse (K); figure(1) plot(u(:,1),u(:,2),'.r'); hold on; drawEllipse(elli,'linewidth',2); hold off; axis tight; endfunction cov2ellipse_demo (K); ## This is what we get with "demo cov2ellipse" cov2ellipse_demo (10*K); cov2ellipse_demo (0.1*K); ###################################################################### This is fixed by taking the square root of the eigenvalues obtained by svd(). The second problem is that the axis orientation is wrong, evidenced in the code below: ###################################################################### K = [2 -1; -1 2]; cov2ellipse_demo (K) ###################################################################### This happens because the wrong elements of the eigenvectors are taken. The patch attached below fixes both problems. Rafael |