nag_normal_pdf_vector (g01kqc) (PDF version)
g01 Chapter Contents
g01 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_normal_pdf_vector (g01kqc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_normal_pdf_vector (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>
#include <nagg01.h>
void  nag_normal_pdf_vector (Nag_Boolean ilog, Integer lx, const double x[], Integer lxmu, const double xmu[], Integer lxstd, const double xstd[], double pdf[], Integer ivalid[], NagError *fail)

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_BooleanInput
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 IntegerInput
On entry: the length of the array x.
Constraint: lx>0.
3:     x[lx] const doubleInput
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 IntegerInput
On entry: the length of the array xmu.
Constraint: lxmu>0.
5:     xmu[lxmu] const doubleInput
On entry: μi, the means with μi=xmu[j], j=i-1 mod lxmu.
6:     lxstd IntegerInput
On entry: the length of the array xstd.
Constraint: lxstd>0.
7:     xstd[lxstd] const doubleInput
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] doubleOutput
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] IntegerOutput
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 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.2.1.2 in the Essential Introduction 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.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 3.6.6 in the Essential Introduction for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction 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

Not applicable.

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

nag_normal_pdf_vector (g01kqc) (PDF version)
g01 Chapter Contents
g01 Chapter Introduction
NAG Library Manual

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