G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG01KAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G01KAF returns the value of the probability density function (PDF) for the Normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma }^{2}$ at a point $x$.

## 2  Specification

 FUNCTION G01KAF ( X, XMEAN, XSTD, IFAIL)
 REAL (KIND=nag_wp) G01KAF
 INTEGER IFAIL REAL (KIND=nag_wp) X, XMEAN, XSTD

## 3  Description

The Normal distribution has probability density function (PDF)
 $fx = 1 σ ⁢ 2π e -x-μ2/2σ2 , σ>0 .$

None.

## 5  Parameters

1:     $\mathrm{X}$ – REAL (KIND=nag_wp)Input
On entry: $x$, the value at which the PDF is to be evaluated.
2:     $\mathrm{XMEAN}$ – REAL (KIND=nag_wp)Input
On entry: $\mu$, the mean of the Normal distribution.
3:     $\mathrm{XSTD}$ – REAL (KIND=nag_wp)Input
On entry: $\sigma$, the standard deviation of the Normal distribution.
Constraint: $z<{\mathbf{XSTD}}\sqrt{2\pi }<1.0/z$, where $z={\mathbf{X02AMF}}\left(\right)$, the safe range parameter.
4:     $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
If ${\mathbf{IFAIL}}\ne {\mathbf{0}}$, then G01KAF returns $0.0$.
${\mathbf{IFAIL}}=1$
On entry, ${\mathbf{XSTD}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{XSTD}}×\sqrt{2.0\pi }>U$, where $U$ is the safe range parameter as defined by X02AMF.
${\mathbf{IFAIL}}=2$
Computation abandoned owing to underflow of $\frac{1}{\left(\sigma ×\sqrt{2\pi }\right)}$.
${\mathbf{IFAIL}}=3$
Computation abandoned owing to an internal calculation overflowing.
This rarely occurs, and is the result of extreme values of the parameters X, XMEAN or XSTD.
${\mathbf{IFAIL}}=-99$
See Section 3.8 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

Not applicable.

Not applicable.

None.

## 10  Example

This example prints the value of the Normal distribution PDF at four different points X with differing XMEAN and XSTD.

### 10.1  Program Text

Program Text (g01kafe.f90)

### 10.2  Program Data

Program Data (g01kafe.d)

### 10.3  Program Results

Program Results (g01kafe.r)