Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_specfun_cdf_normal (s15ab)

## Purpose

nag_specfun_cdf_normal (s15ab) returns the value of the cumulative Normal distribution function, $P\left(x\right)$, via the function name.

## Syntax

[result, ifail] = s15ab(x)
[result, ifail] = nag_specfun_cdf_normal(x)

## Description

nag_specfun_cdf_normal (s15ab) evaluates an approximate value for the cumulative Normal distribution function
 $Px=12π∫-∞xe-u2/2du.$
The function is based on the fact that
 $Px=12erfc-x2$
and it calls nag_specfun_erfc_real (s15ad) to obtain a value of $\mathit{erfc}$ for the appropriate argument.

## References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{x}$ – double scalar
The argument $x$ of the function.

None.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The result of the function.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

There are no failure exits from this function. The argument ifail is included for consistency with other functions in this chapter.

## Accuracy

Because of its close relationship with $\mathit{erfc}$, the accuracy of this function is very similar to that in nag_specfun_erfc_real (s15ad). If $\epsilon$ and $\delta$ are the relative errors in result and argument, respectively, they are in principle related by
 $ε≃ x e -12 x2 2πPx δ$
so that the relative error in the argument, $x$, is amplified by a factor, $\frac{x{e}^{-\frac{1}{2}{x}^{2}}}{\sqrt{2\pi }P\left(x\right)}$, in the result.
For $x$ small and for $x$ positive this factor is always less than one and accuracy is mainly limited by machine precision.
For large negative $x$ the factor behaves like $\text{}\sim {x}^{2}$ and hence to a certain extent relative accuracy is unavoidably lost.
However the absolute error in the result, $E$, is given by
 $E≃ x e -12 x2 2π δ$
so absolute accuracy can be guaranteed for all $x$.

None.

## Example

This example reads values of the argument $x$ from a file, evaluates the function at each value of $x$ and prints the results.
```function s15ab_example

fprintf('s15ab example results\n\n');

x = [-20   -1     0    1    2    20];
n = size(x,2);
result = x;

for j=1:n
[result(j), ifail] = s15ab(x(j));
end

disp('      x          P(x)');
fprintf('%12.3e%12.3e\n',[x; result]);

```
```s15ab example results

x          P(x)
-2.000e+01   2.754e-89
-1.000e+00   1.587e-01
0.000e+00   5.000e-01
1.000e+00   8.413e-01
2.000e+00   9.772e-01
2.000e+01   1.000e+00
```