Cdf of multivariate normal in distributions.jl


#1

I’m trying to use the cdf of a multivariate normal distribution using Distributions.jl.
While

d = Normal(0,1)
d2 = MvNormal([0.;0.], [1. 0.;0. 1.])
x = [1. ; 2.]
e1 = cdf(d,x[1])
e2 = cdf(d,x[2])

works (as long as the mean vector and the var-cov matrix for the multivariate normal are Floats ), I get an error whenever I write
e3 = cdf(d2,x)
Here is the error message:

ERROR: MethodError: no method matching cdf(::Distributions.MvNormal{Float64,PDMats.PDMat{Float64,Array{Float64,2}},Array{Float64,1}}, ::Array{Float64,1})
Closest candidates are:
  cdf(::Distributions.Distribution{Distributions.Univariate,S<:Distributions.ValueSupport}, ::AbstractArray{T,N}) at /Applications/JuliaPro-0.5.1.1.app/Contents/Resources/pkgs-0.5.1.1/v0.5/Distributions/src/univariates.jl:205

Does the cdf function support multivariate distributions? I couldn’t find anything on this in the documentation of Distributions.jl.


#2

No, there is not a cdf for the multivariate normal. Generally, it is a slightly complicated computation. We have some code evaluating the bi- and trivariate case but it hasn’t been used for a long time. For some time, I’ve wanted a dedicated package for multivariate distributions that would be using StaticArrays for storage. The cdf code for fit well in such a package.


#3

That’s a shame. We really should have something in Julia for this. I’ll work around it using PyCall for the time being.


#4

Are you mainly interested in 2D and 3D or higher dimensions? Do you know how higher dimensions are handled in Python?


#5

My interest is currently for 2D. I have no idea how higher dimensions are handled in Python right now but hopefully I’ll learn a little bit about it in the next few days.


#6

If you are interested in spending a little time on it, we could probably get the 2D Julia version working again. If we do it with StaticArrays it will also be extremely fast.


#7

Hello,
I am also interested in a julia version for the cdf for 2D normal. I might be able to spend a bit time on this, but where can I find the version that exists already? I am not familiar with StaticArrays though, but I can certainly give it a try.
Thanks!


#9

It is here https://github.com/JuliaStats/StatsFuns.jl/blob/e21bc26b1773aeb86bc8df4832db9c371d09ba2b/src/tvpack.jl#L338