NAG CL Interface
g01kqc (pdf_​normal_​vector)

1 Purpose

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

2 Specification

#include <nag.h>
void  g01kqc (Nag_Boolean ilog, Integer lx, const double x[], Integer lxmu, const double xmu[], Integer lxstd, const double xstd[], double pdf[], Integer ivalid[], NagError *fail)
The function may be called by the names: g01kqc, nag_stat_pdf_normal_vector or nag_normal_pdf_vector.

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 function are designed to allow maximum flexibility in the supply of vector arguments 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 Arguments

1: ilog Nag_Boolean Input
On entry: the value of ilog determines whether the logarithmic value is returned in PDF.
ilog=Nag_FALSE
fxi,μi,σi, the probability density function is returned.
ilog=Nag_TRUE
logfxi,μi,σi, the logarithm of the probability density function is returned.
2: lx Integer Input
On entry: the length of the array x.
Constraint: lx>0.
3: x[lx] const double Input
On entry: xi, the values at which the PDF is to be evaluated with xi=x[j], j=i-1 mod lx, for i=1,2,,maxlx,lxstd,lxmu.
4: lxmu Integer Input
On entry: the length of the array xmu.
Constraint: lxmu>0.
5: xmu[lxmu] const double Input
On entry: μi, the means with μi=xmu[j], j=i-1 mod lxmu.
6: lxstd Integer Input
On entry: the length of the array xstd.
Constraint: lxstd>0.
7: xstd[lxstd] const double Input
On entry: σi, the standard deviations with σi=xstd[j], j=i-1 mod lxstd.
Constraint: xstd[j-1]0.0, for j=1,2,,lxstd.
8: pdf[dim] double Output
Note: the dimension, dim, of the array pdf must be at least maxlx,lxstd,lxmu.
On exit: fxi,μi,σi or logfxi,μi,σi.
9: ivalid[dim] Integer Output
Note: the dimension, dim, of the array ivalid must be at least maxlx,lxstd,lxmu.
On exit: ivalid[i-1] indicates any errors with the input arguments, with
ivalid[i-1]=0
No error.
ivalid[i-1]=1
σi<0.
10: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_ARRAY_SIZE
On entry, array size=value.
Constraint: lx>0.
On entry, array size=value.
Constraint: lxmu>0.
On entry, array size=value.
Constraint: lxstd>0.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NW_IVALID
On entry, at least one value of xstd was invalid.
Check ivalid for more information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

g01kqc 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 xi with differing μi and σi.

10.1 Program Text

Program Text (g01kqce.c)

10.2 Program Data

Program Data (g01kqce.d)

10.3 Program Results

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