When sampling from a multivariate normal using Armadillo in a long simulation I got error: chol() failed to converge. So I decided to slightly perturb sigma in order to avoid my simulation being stopped often with the following code:
try {
R = chol(sigma);
} catch ( ... ) {
sigma += eye(sigma.n_rows,sigma.n_rows) * 1e-6;
R = chol(sigma);
}
However, this code seems to be slowing things down and I would like to avoid the error message being returned.
How can I fix this?
Aucun commentaire:
Enregistrer un commentaire