NAG FL Interface
g01kaf (pdf_​normal)

Settings help

FL Name Style:


FL Specification Language:


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

Fortran Interface
Function g01kaf ( x, xmean, xstd, ifail)
Real (Kind=nag_wp) :: g01kaf
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: x, xmean, xstd
C Header Interface
#include <nag.h>
double  g01kaf_ (const double *x, const double *xmean, const double *xstd, Integer *ifail)
The routine may be called by the names g01kaf or nagf_stat_pdf_normal.

3 Description

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

4 References

None.

5 Arguments

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 Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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.
ifail=1
On entry, xstd=value.
Constraint: xstd×2.0π>U, where U is the safe range parameter as defined by x02amf.
ifail=2
Computation abandoned owing to underflow of 1(σ×2π).
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.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g01kaf is not threaded in any implementation.

9 Further Comments

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)
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 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). μ=0, σ=0.3 μ=0, σ=1 μ=1, σ=0.6 gnuplot_plot_1 gnuplot_plot_2 gnuplot_plot_3