# NAG Library Routine Document

## 1Purpose

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$.

## 2Specification

Fortran Interface
 Function g01kaf ( x, xstd,
 Real (Kind=nag_wp) :: g01kaf Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: x, xmean, xstd
#include <nagmk26.h>
 double g01kaf_ (const double *x, const double *xmean, const double *xstd, Integer *ifail)

## 3Description

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

None.

## 5Arguments

1:     $\mathbf{x}$ – Real (Kind=nag_wp)Input
On entry: $x$, the value at which the PDF is to be evaluated.
2:     $\mathbf{xmean}$ – Real (Kind=nag_wp)Input
On entry: $\mu$, the mean of the Normal distribution.
3:     $\mathbf{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:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value  is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value  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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-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 arguments x, xmean or xstd.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

Not applicable.

## 8Parallelism and Performance

g01kaf is not threaded in any implementation.

None.

## 10Example

This example prints the value of the Normal distribution PDF at four different points x with differing xmean and xstd.

### 10.1Program Text

Program Text (g01kafe.f90)

### 10.2Program Data

Program Data (g01kafe.d)

### 10.3Program Results

Program Results (g01kafe.r)