# Φ(−600) = 6.546588 205807 692852 105927 713888 108782 119412 831853 177211 16943e − 78177

**URL:** <https://discourse.julialang.org/t/600-6-546588-205807-692852-105927-713888-108782-119412-831853-177211-16943e-78177/87309>\
**Category:** Statistics\
**Tags:** distributions\
**Created:** [September 15, 2022, 11:25am UTC](https://discourse.julialang.org/t/600-6-546588-205807-692852-105927-713888-108782-119412-831853-177211-16943e-78177/87309 "2022-09-15T11:25:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackeneth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blackeneth/32/10353_2.png) [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Post date:** [September 15, 2022, 11:25am UTC](https://discourse.julialang.org/t/600-6-546588-205807-692852-105927-713888-108782-119412-831853-177211-16943e-78177/87309/1 "2022-09-15T11:25:40Z")

</div>

The paper [_Approximations to the Normal Distribution Function and An Extended Table for the Mean Range of the Normal Variables by Kiani, M and Panaretos, J and Psarakis, S and Saleem, M (2008)_](https://mpra.ub.uni-muenchen.de/68045/1/Panaretos-JIRSS2008(57-72)ft.pdf) reviews algorithms for computing the CDF of the univariate Normal distribution. Then they develop some new approximations.

From use of their new approximations, we learn that:

Φ(−600) = 6.54658820580769285210592771388810878211941283185317721116943e − 78177

This required them to compute 1080 terms of their series approximation.

Now Julia:

```julia
julia> sn=Normal(BigFloat("0.0"),BigFloat("1.0"))
Normal{BigFloat}(μ=0.0, σ=1.0)

julia> cdf(sn,-600)
6.546588205807692852105927713888108782119412831853177211169430430310177386453905e-78177

```

How did Julia do it?

Best I can figure out, the univariate Normal CDF is computed using the error function from the GNU [MFPR library](https://www.mpfr.org/index.html). Apparently it just keeps going until all the bits of BigFloat accurate.

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [September 15, 2022, 12:39pm UTC](https://discourse.julialang.org/t/600-6-546588-205807-692852-105927-713888-108782-119412-831853-177211-16943e-78177/87309/2 "2022-09-15T12:39:17Z")

</div>

In Base Julia:

```julia
function my_erfc(x::BigFloat)
   z = BigFloat()
   ccall((:mpfr_erfc, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, Base.MPFR.ROUNDING_MODE[])
   return z
end

my_erfc(big(600.0)*inv(sqrt(big(2))))/2

```

(adapting code from IrrationalConstants, StatsFuns and SpecialFunctions)

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 15, 2022, 12:46pm UTC](https://discourse.julialang.org/t/600-6-546588-205807-692852-105927-713888-108782-119412-831853-177211-16943e-78177/87309/3 "2022-09-15T12:46:18Z")

</div>

> [@blackeneth](#):
>
> Best I can figure out, the univariate Normal CDF is computed using the error function from the GNU [MFPR library](https://www.mpfr.org/index.html).

Yup, and [MPFR uses an asymptotic series](https://gitlab.inria.fr/mpfr/mpfr/-/blob/master/src/erfc.c) for the complementary error function of large arguments (whenever x^2 \ge p \log2, where p is the precision), which converges fairly quickly in this regime.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/6/563f28aa7234eb138edcdcfd0c172f516af781f6.jpeg)

e.g. you get a decent approximation with only two terms:

```julia
julia> my_erfc_asympt(z) = (1 - 1/2z^2) * exp(-z^2) / (√π*z)
my_erfc_asympt (generic function with 1 method)

julia> setprecision(52)
52

julia> my_erfc_asympt(big(600.0)*inv(sqrt(big(2))))/2
6.5465882048940283e-78177

```

---

<div class="post-metadata">

**Author:** ![blackeneth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blackeneth/32/10353_2.png) [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Post date:** [September 16, 2022, 5:50am UTC](https://discourse.julialang.org/t/600-6-546588-205807-692852-105927-713888-108782-119412-831853-177211-16943e-78177/87309/4 "2022-09-16T05:50:19Z")

</div>

Thank you for posting the expression used. I had tried to find it, but never found the right path to drill down to it.
