g01 Chapter Contents
g01 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_normal_pdf_vector (g01kqc)

## 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 #include
 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 ${\mu }_{i}$, variance ${{\sigma }_{i}}^{2}$; has probability density function (PDF)
 $f xi,μi,σi = 1 σi⁢2π 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.

None.

## 5  Arguments

1:     ilogNag_BooleanInput
On entry: the value of ilog determines whether the logarithmic value is returned in PDF.
${\mathbf{ilog}}=\mathrm{Nag_FALSE}$
$f\left({x}_{i},{\mu }_{i},{\sigma }_{i}\right)$, the probability density function is returned.
${\mathbf{ilog}}=\mathrm{Nag_TRUE}$
$\mathrm{log}\left(f\left({x}_{i},{\mu }_{i},{\sigma }_{i}\right)\right)$, the logarithm of the probability density function is returned.
Constraint: ${\mathbf{ilog}}=\mathrm{Nag_FALSE}$ or $\mathrm{Nag_TRUE}$.
2:     lxIntegerInput
On entry: the length of the array x.
Constraint: ${\mathbf{lx}}>0$.
3:     x[lx]const doubleInput
On entry: ${x}_{i}$, the values at which the PDF is to be evaluated with ${x}_{i}={\mathbf{x}}\left[j\right]$, , for $i=1,2,\dots ,\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{lx}},{\mathbf{lxstd}},{\mathbf{lxmu}}\right)$.
4:     lxmuIntegerInput
On entry: the length of the array xmu.
Constraint: ${\mathbf{lxmu}}>0$.
5:     xmu[lxmu]const doubleInput
On entry: ${\mu }_{i}$, the means with ${\mu }_{i}={\mathbf{xmu}}\left[j\right]$, .
6:     lxstdIntegerInput
On entry: the length of the array xstd.
Constraint: ${\mathbf{lxstd}}>0$.
7:     xstd[lxstd]const doubleInput
On entry: ${\sigma }_{i}$, the standard deviations with ${\sigma }_{i}={\mathbf{xstd}}\left[j\right]$, .
Constraint: ${\mathbf{xstd}}\left[\mathit{j}-1\right]\ge 0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{lxstd}}$.
8:     pdf[$\mathit{dim}$]doubleOutput
Note: the dimension, dim, of the array pdf must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{lx}},{\mathbf{lxstd}},{\mathbf{lxmu}}\right)$.
On exit: $f\left({x}_{i},{\mu }_{i},{\sigma }_{i}\right)$ or $\mathrm{log}\left(f\left({x}_{i},{\mu }_{i},{\sigma }_{i}\right)\right)$.
9:     ivalid[$\mathit{dim}$]IntegerOutput
Note: the dimension, dim, of the array ivalid must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{lx}},{\mathbf{lxstd}},{\mathbf{lxmu}}\right)$.
On exit: ${\mathbf{ivalid}}\left[i-1\right]$ indicates any errors with the input arguments, with
${\mathbf{ivalid}}\left[i-1\right]=0$
No error.
${\mathbf{ivalid}}\left[i-1\right]=1$
${\sigma }_{i}<0$.
10:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ARRAY_SIZE
On entry, $\text{array size}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lx}}>0$.
On entry, $\text{array size}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lxmu}}>0$.
On entry, $\text{array size}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lxstd}}>0$.
On entry, argument $〈\mathit{\text{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.
NW_IVALID
On entry, at least one value of xstd was invalid.

Not applicable.

None.

## 9  Example

This example prints the value of the Normal distribution PDF at four different points ${x}_{i}$ with differing ${\mu }_{i}$ and ${\sigma }_{i}$.

### 9.1  Program Text

Program Text (g01kqce.c)

### 9.2  Program Data

Program Data (g01kqce.d)

### 9.3  Program Results

Program Results (g01kqce.r)