G01KAF (PDF version)
G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


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.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G01KAF returns the value of the probability density function (PDF) for the Normal (Gaussian) distribution with mean μ and variance σ2 at a point x.

2  Specification

REAL (KIND=nag_wp) G01KAF

3  Description

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

4  References


5  Parameters

1:     X – REAL (KIND=nag_wp)Input
On entry: x, the value at which the PDF is to be evaluated.
2:     XMEAN – REAL (KIND=nag_wp)Input
On entry: μ, the mean of the Normal distribution.
3:     XSTD – REAL (KIND=nag_wp)Input
On entry: σ, the standard deviation of the Normal distribution.
Constraint: z<XSTD2π<1.0/z, where z=X02AMF, the safe range parameter.
4:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ 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​ 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 -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry 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 IFAIL0, then G01KAF returns 0.0.
XSTD2.0πz, where z=X02AMF, the safe range parameter.
XSTD2.0π1/z, where z=X02AMF, the safe range parameter.
An internal calculation would overflow. This rarely occurs, and is the result of extreme values of the parameters X, XMEAN or XSTD.

7  Accuracy

Not applicable.

8  Further Comments


9  Example

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

9.1  Program Text

Program Text (g01kafe.f90)

9.2  Program Data

Program Data (g01kafe.d)

9.3  Program Results

Program Results (g01kafe.r)

Produced by GNUPLOT 4.4 patchlevel 0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 -3 -2 -1 0 1 2 3 y x Example Program Plots of the Gaussian Function (or Normal Distribution). m=0, s=0.3 m=0, s=1 m=1, s=0.6

G01KAF (PDF version)
G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012