The Excel sheet contains various codes for the standard cumulative normal
distribution for dimensions 1, 2 and 3. Exactness is ~ 15 decimal places,
the various solutions are compared (and they can be ported, they are not
specific for Excel).
Some solutions are due to Genz and have been ported to VB by Graeme West,
which I modified successively.
References on the web are:
http://www.sci.wsu.edu/math/faculty/genz/homepage for code and explaining
papers, http://www.finmod.co.za/resources.html for the VB version.
For dim=1 a series approach by Marsaglia and the solution given at Genz
are compared. It turns out that for small values an interpolation should
be used (cdfN_Hart), for medium size Marsaglia cdfN_Marsaglia is worth its
cost and for larger ones an asymptotic is the choice.
In cdfN_Marsaglia functions are 'Taylored' around 0,...,7 and this should
stop after 20 steps with Excel's exactness. The asymptotic I think is due
to Legendre (and for example is used in Maple).
For dim=2 I switched to a cdfN1 stated above and then the Genz approach has
fine results. This is compared using an external integratorXL.dll as library
with call-backs to speed up numerical integration (correct the pathes in
m_DeclareDLL if neccessary).
For dim 2 and lower correlation Marsaglia's method can be used to write
down recursions for the Taylor series, while for higher correlations it is
better to use a method of Vasicek (which I modified a bit), both more or
less are recursions for the incomplete Gamma function involved. For both
the expansion is stopped by machine precision (and the cdfN1 used). The
code looks a bit ugly as I generated it using Maple procedures (to have
comparable results for tests). Note that the series approach is limited
by ~ 1e-15 for exactness: a decomposition in two (very exact) summands is
done, but a system exactness 1 + eps <> 1 is involved.
Thus the method of Drezner & Wesolowsky given by Genz results in good speed
and exactness up to 14 or 15 digits - based on a good choice for cdfN1:
may be in Fortran it is not neccessary to modify the orignal cdfN, but at
least Excel needs that.
For dim=3 only the result through integration is upported. Note that this
does not say that is gives 'exact' results:
Tests using Maple do show errors if the correlation matrix becomes almost
numerical singular. But one can merely have excellent and fast result results
with such limited exactness as Excel and a usual 15 digit environment gives
for such a problem.
AVt, Dec 2005