Multivariate Normal Distribution

Hi there Could somebody give me a clear example about how to construct a MVND using the syntaxis given by the Distribution Pkg. I know that with Distributions.jl it is possible to generate a MVND just as it is possible to do an univariate one. The thing is that since I knew using Julia I would like to have some advice on how to generate a MVND. Grettings for the retro

See ?MvNormal, it is documented. Eg

MvNormal(mu, sigma)

where mu is a vector and sigma is a PSD matrix. There are other constructors, see the docstrings.

1 Like

The name MvNormal seems difficult to discover.

1 Like

I am not sure I understand why you think this, it is right there in the docs:

I know the information is there, its just that I dont know exactly how to build the vectors of mean and covariance given by the syntaxis I just need an example on how the construction is using some numbers I do understand the theory of the bivariate distribution but I,m stuck cause I dont know how to build the syntaxis structure like Julia says.

Sorry for the inconvinient



using Distributions, LinearAlgebra
MvNormal(ones(3), Diagonal(ones(3)))

but you may benefit from just reading through the manual first:

Thank you very much for the approach and sure I will read the manual indeed

See some examples in Section 3.7 here:

  • A Google search for “Julia multivariate normal” did not take me to that page; and
  • you can’t guess the name using tab completion at the REPL.
    Indeed, I find it hard to remember the name MvNormal even after seeing it a few times. Maybe MultivariateNormal would be better?

It was already established that the relevant package is Distributions.

While being able to guess things in the REPL via completion is indeed nice, I don’t think it is reasonable to expect to rely on that for everything. Quite a bit if effort goes into writing good docs for Julia and some (but of course, not all) packages, so looking that up should be the first thing to do.

I am puzzled why people don’t read package docs or the Julia manual. Do they not expect them to exist, are they just difficult to find, or they don’t think it would be useful?

Why just not Normal(Array{T,1},Array{T,2}) ?

You should not be so puzzled over questions like this. People do read docs but the documentation is not always so good.

If you want to achieve something, you browse the documentation until you find a solution. Nobody reads the whole doc before they start coding. Just the other day I discovered diagind. Until now I had just computed the indices manually.

There should be more code examples that people can just copy and start modifying. This is why I like or

Another point is peoples expectations. You know C++ is low level and Matlab is high level. But what is Julia? Some parts are abstracted to obscurity while some are unnecessary low. The level of abstraction is very uneven.

As an example, I give you Plots.jl. It just works, until it doesn’t and the documentation does not tell you what to do. If you want to create a color palette, should you try high abstraction or low abstraction?

Possibly — which is a great opportunity to improve on it by making a PR.

You may not, I usually do. The “whole” documentation is not that long for most packages, and can be read through within 10–30 minutes. For larger “meta” packages like DiffEq or Plots, it is usually easy to find the relevant section and just read that.

Also just to add I don’t think the Distributions.jl docs can be accused of being “not so good” in this particular case - there’s a page for multivariate distributions that is linked in the index right on the landing page, so it should be reasonably easy to find relevant info on multivariate distributions: