I’m trying to use the cdf of a multivariate normal distribution in Julia 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
It seems like the cdf function does not support multivariate distributions. I couldn’t find anything on this in the documentation of Distributions.jl. Is there any other way to find a cdf of a multivariate normal in Julia?
Now that I look into PyCall and SciPy, it turns out that scipy.stats have multivariate_normal but doesn’t have cdf defined as a method. Same issue with Julia.
Hmm. That’s disappointing. At a pinch you could use Monte Carlo, replacing the probability of your random vector X being less than a fixed vector x with the empirical probability. If speed is not vital it will give you reasonable results.