hide long namesshow long names
hide short namesshow short names
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 μμ and variance σ2σ2 at a point xx.

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 .

References

None.

Parameters

Compulsory Input Parameters

1:     x – double scalar
xx, the value at which the PDF is to be evaluated.
2:     xmean – double scalar
μμ, the mean of the Normal distribution.
3:     xstd – double scalar
σσ, the standard deviation of the Normal distribution.
Constraint: z < xstdsqrt(2π) < 1.0 / zz<xstd2π<1.0/z, where z = x02am()z=x02am(), the safe range parameter.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
If ifail0ifail0, then nag_stat_pdf_normal (g01ka) returns 0.00.0.
  ifail = 1ifail=1
Constraint: xstd × sqrt(2.0π) > x02am()xstd×2.0π>x02am().
  ifail = 2ifail=2
Computation abandoned owing to underflow of 1/((σ × sqrt(2π)))1(σ×2π).
  ifail = 3ifail=3
Computation abandoned owing to an internal calculation overflowing.

Accuracy

Not applicable.

Further Comments

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