I was using the function mvn.mvnun()
in the scipy.stats
module to calculate the CDF of a given multivariate normal distribution in my paper. The reviewer asked me how I estimated the CDF since the CDF has no closed-form. I guess a sampling method might be used. To find out how it works, I searched the scipy
source code repo. However, in the scipy.stats
folder, I didn't see mvn.py
, I saw mvn.pyf
instead.
In the file, mvn.mvnun
seems to be defined as follows,
! -*- f90 -*-
! Note: the context of this file is case sensitive.
python module mvn ! in
interface ! in :mvn
subroutine mvnun(d,n,lower,upper,means,covar,maxpts,abseps,releps,value,inform) ! in :mvn:mvndst.f
integer intent(hide) :: d=shape(means,0)
integer intent(hide) :: n=shape(means,1)
double precision dimension(d) :: lower
double precision dimension(d) :: upper
double precision dimension(d,n) :: means
double precision dimension(d,d) :: covar
integer intent(optional) :: maxpts=d*1000
double precision intent(optional) :: abseps=1e-6
double precision intent(optional) :: releps=1e-6
double precision intent(out) :: value
integer intent(out) :: inform
end subroutine mvnun
However, there is no detailed definition of that function. I was wondering where I can find the source code for mvnun
that informs me how it calculates the CDF?
The implementation is written in Fortran. That pyf
file defines the interface for the Fortran function in mvndst.f