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

NAG Library Routine Document

G01KQF

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

G01KQF returns a number of values of the probability density function (PDF), or its logarithm, for the Normal (Gaussian) distributions.

2  Specification

SUBROUTINE G01KQF ( ILOG, LX, X, LXMU, XMU, LXSTD, XSTD, PDF, IVALID, IFAIL)
INTEGER  ILOG, LX, LXMU, LXSTD, IVALID(*), IFAIL
REAL (KIND=nag_wp)  X(LX), XMU(LXMU), XSTD(LXSTD), PDF(*)

3  Description

The Normal distribution with mean μi, variance σi2; has probability density function (PDF)
f xi,μi,σi = 1 σi2π e -xi-μi2/2σi2 ,  σi>0 .
The input arrays to this routine are designed to allow maximum flexibility in the supply of vector parameters by re-using elements of any arrays that are shorter than the total number of evaluations required. See Section 2.6 in the G01 Chapter Introduction for further information.

4  References

None.

5  Parameters

1:     ILOG – INTEGERInput
On entry: the value of ILOG determines whether the logarithmic value is returned in PDF.
ILOG=0
fxi,μi,σi, the probability density function is returned.
ILOG=1
logfxi,μi,σi, the logarithm of the probability density function is returned.
Constraint: ILOG=0 or 1.
2:     LX – INTEGERInput
On entry: the length of the array X.
Constraint: LX>0.
3:     X(LX) – REAL (KIND=nag_wp) arrayInput
On entry: xi, the values at which the PDF is to be evaluated with xi=Xj, j=i-1 mod LX+1, for i=1,2,,maxLX,LXSTD,LXMU.
4:     LXMU – INTEGERInput
On entry: the length of the array XMU.
Constraint: LXMU>0.
5:     XMU(LXMU) – REAL (KIND=nag_wp) arrayInput
On entry: μi, the means with μi=XMUj, j=i-1 mod LXMU+1.
6:     LXSTD – INTEGERInput
On entry: the length of the array XSTD.
Constraint: LXSTD>0.
7:     XSTD(LXSTD) – REAL (KIND=nag_wp) arrayInput
On entry: σi, the standard deviations with σi=XSTDj, j=i-1 mod LXSTD+1.
Constraint: XSTDj0.0, for j=1,2,,LXSTD.
8:     PDF(*) – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array PDF must be at least maxLX,LXSTD,LXMU.
On exit: fxi,μi,σi or logfxi,μi,σi.
9:     IVALID(*) – INTEGER arrayOutput
Note: the dimension of the array IVALID must be at least maxLX,LXSTD,LXMU.
On exit: IVALIDi indicates any errors with the input arguments, with
IVALIDi=0
No error.
IVALIDi=1
σi<0.
10:   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:
IFAIL=1
On entry, at least one value of XSTD was invalid.
Check IVALID for more information.
IFAIL=2
On entry, ILOG=value.
Constraint: ILOG=0 or 1.
IFAIL=3
On entry, array size=value.
Constraint: LX>0.
IFAIL=4
On entry, array size=value.
Constraint: LXMU>0.
IFAIL=5
On entry, array size=value.
Constraint: LXSTD>0.

7  Accuracy

Not applicable.

8  Further Comments

None.

9  Example

This example prints the value of the Normal distribution PDF at four different points xi with differing μi and σi.

9.1  Program Text

Program Text (g01kqfe.f90)

9.2  Program Data

Program Data (g01kqfe.d)

9.3  Program Results

Program Results (g01kqfe.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

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

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