Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_pdf_normal (g01ka)

## Purpose

nag_stat_pdf_normal (g01ka) returns the value of the probability density function (PDF) for the Normal (Gaussian) distribution with mean μ$\mu$ and variance σ2${\sigma }^{2}$ at a point x$x$.

## Syntax

[result, ifail] = g01ka(x, xmean, xstd)
[result, ifail] = nag_stat_pdf_normal(x, xmean, xstd)

## Description

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

None.

## Parameters

### Compulsory Input Parameters

1:     x – double scalar
x$x$, the value at which the PDF is to be evaluated.
2:     xmean – double scalar
μ$\mu$, the mean of the Normal distribution.
3:     xstd – double scalar
σ$\sigma$, the standard deviation of the Normal distribution.
Constraint: z < xstdsqrt(2π) < 1.0 / z$z<{\mathbf{xstd}}\sqrt{2\pi }<1.0/z$, where z = x02am()$z=\mathbf{x02am}\left(\right)$, the safe range parameter.

None.

None.

### Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
If ${\mathbf{ifail}}\ne {\mathbf{0}}$, then nag_stat_pdf_normal (g01ka) returns 0.0$0.0$.
ifail = 1${\mathbf{ifail}}=1$
Constraint: xstd × sqrt(2.0π) > x02am()${\mathbf{xstd}}×\sqrt{2.0\pi }>\mathbf{x02am}\left(\right)$.
ifail = 2${\mathbf{ifail}}=2$
Computation abandoned owing to underflow of 1/((σ × sqrt(2π)))$\frac{1}{\left(\sigma ×\sqrt{2\pi }\right)}$.
ifail = 3${\mathbf{ifail}}=3$
Computation abandoned owing to an internal calculation overflowing.

Not applicable.

None.

## Example

function nag_stat_pdf_normal_example
x      = [1, 4, 0.1, 1];
xmean  = [0, 2, 0, 0];
xstd   = [1, 1, 0.01, 10];
result = zeros(4, 1);
fprintf('\n  X             Mean          Standard      Result\n');
fprintf('                              Deviation\n');

for i=1:4
[result(i), ifail] = nag_stat_pdf_normal(x(i), xmean(i), xstd(i));
fprintf('%13.5e %13.5e %13.5e %13.5e\n', x(i), xmean(i), xstd(i), result(i));
end

X             Mean          Standard      Result
Deviation
1.00000e+00   0.00000e+00   1.00000e+00   2.41971e-01
4.00000e+00   2.00000e+00   1.00000e+00   5.39910e-02
1.00000e-01   0.00000e+00   1.00000e-02   7.69460e-21
1.00000e+00   0.00000e+00   1.00000e+01   3.96953e-02

function g01ka_example
x      = [1, 4, 0.1, 1];
xmean  = [0, 2, 0, 0];
xstd   = [1, 1, 0.01, 10];
result = zeros(4, 1);
fprintf('\n  X             Mean          Standard      Result\n');
fprintf('                              Deviation\n');

for i=1:4
[result(i), ifail] = g01ka(x(i), xmean(i), xstd(i));
fprintf('%13.5e %13.5e %13.5e %13.5e\n', x(i), xmean(i), xstd(i), result(i));
end

X             Mean          Standard      Result
Deviation
1.00000e+00   0.00000e+00   1.00000e+00   2.41971e-01
4.00000e+00   2.00000e+00   1.00000e+00   5.39910e-02
1.00000e-01   0.00000e+00   1.00000e-02   7.69460e-21
1.00000e+00   0.00000e+00   1.00000e+01   3.96953e-02

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013