# About normcdf() function integration method

3 messages
Open this post in threaded view
|

## About normcdf() function integration method

 Hello: I'm teaching this semester some maths and I'll explain numerical integration methods. In one exercise the students must write a script in order to compute areas below the normal distribution curve and then use the normcdf() function to check the results and the theoretical error level for the Simpson and the trapezoidal methods. My question is, which method for numerical integration uses Octave in normcdf()? If uses the trapezoidal or Simpson method, what is the level of discretization? Thanks -- ***************************************** José Luis García Pallero [hidden email] (o< / / \ V_/_ Use Debian GNU/Linux and enjoy! *****************************************
Open this post in threaded view
|

## RE: About normcdf() function integration method

 It probably uses the built in erf function that comes with the C math library.  Those are usually computed using quite involved techniques (series or rational function approximations that depend upon which range x falls into). ________________________________________ From: Octave-maintainers [octave-maintainers-bounces+stephen=[hidden email]] on behalf of José Luis García Pallero [[hidden email]] Sent: Monday, October 16, 2017 8:23 AM To: Octave Maintainers; Octave Maintainers List Subject: About normcdf() function integration method Hello: I'm teaching this semester some maths and I'll explain numerical integration methods. In one exercise the students must write a script in order to compute areas below the normal distribution curve and then use the normcdf() function to check the results and the theoretical error level for the Simpson and the trapezoidal methods. My question is, which method for numerical integration uses Octave in normcdf()? If uses the trapezoidal or Simpson method, what is the level of discretization? Thanks -- ***************************************** José Luis García Pallero [hidden email] (o< / / \ V_/_ Use Debian GNU/Linux and enjoy! *****************************************
Open this post in threaded view
|

## Re: About normcdf() function integration method

In reply to this post by José Luis García Pallero
On 10/16/2017 09:00 AM, [hidden email] wrote:
 Subject: About normcdf() function integration method From: José Luis García Pallero [hidden email] Date: 10/16/2017 06:23 AM
 To: Octave Maintainers [hidden email], Octave Maintainers List [hidden email]
 List-Post: [hidden email] Content-Transfer-Encoding: quoted-printable Precedence: list MIME-Version: 1.0 Message-ID: [hidden email] Content-Type: text/plain; charset="UTF-8" Message: 2

```Hello:

I'm teaching this semester some maths and I'll explain numerical
integration methods. In one exercise the students must write a script
in order to compute areas below the normal distribution curve and then
use the normcdf() function to check the results and the theoretical
error level for the Simpson and the trapezoidal methods.

My question is, which method for numerical integration uses Octave in
normcdf()? If uses the trapezoidal or Simpson method, what is the
level of discretization?

Thanks```

The function normcdf() is implemented in an m-file which means you can just look at the source to see what Octave is doing.  Inside normcdf.m there is this line

cdf = stdnormal_cdf ((x - mu) / sigma);

So Octave is centering and scaling the distribution, and then using the CDF for the standard normal function with mu = 0, sigma = 1.

stdnormal_cdf is also implemented as an m-file.  Inside that one finds

cdf = erfc (x / (-sqrt(2))) / 2;

Octave relies on the C++ standard library for the complimentary error function erfc.

For students, definitely have them try trapz() or one of the 1-D integrators (quad, quadv, quadgk, etc.).

--Rik