[mlpack-git] [mlpack] GaussianDistribution should cache covariance matrix factorization (#385)

Stephen Tu notifications at github.com
Fri Jan 16 19:38:38 EST 2015


I thought about this, but I would just have made a setter method. How often do you change covariance?Would this be ok?

```
GaussianDistribution g(mean, covariance); // This factorizes 'covariance'.

// Recalculate covariance.
arma::mat newCovariance(g.Covariance().n_rows, g.Covariance().n_cols);
newCovariance.zeros();
for (size_t i = 0; i < numPoints; ++i)
  newCovariance += x.col(i) * x.col(i).t(); // Or something like that.

// Set and factorize newCovariance
g.Covariance(std::move(newCovariance));
```

No un-necessary copy, but needs un-necessary storage.  Forcing the user to call `InvertCovariance()` is too error prone IMO. 

---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/385#issuecomment-70345147
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20150116/e035f26a/attachment.html>


More information about the mlpack-git mailing list