Yesterday I described my experiences implementing multivariate Gaussian distributions in Julia. I’ve since repeated the exercise in Clojure, for any time you might need to do such a thing on the JVM. I’m using core.matrix for array operations.

μ, again is just `(mean x)`

.

To calculate the covariance matrix:

This is just Σ = (X - μ)’(X - μ) / n (where n is the number of examples).

And now that we have μ and Σ, we can use this function for probability:

I’ve wrapped the code for this up in a library, available on Github.