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_vector (g01kq)

Purpose

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

Syntax

[pdf, ivalid, ifail] = g01kq(ilog, x, xmu, xstd, 'lx', lx, 'lxmu', lxmu, 'lxstd', lxstd)
[pdf, ivalid, ifail] = nag_stat_pdf_normal_vector(ilog, x, xmu, xstd, 'lx', lx, 'lxmu', lxmu, 'lxstd', lxstd)

Description

The Normal distribution with mean μiμi, variance σi2σi2; has probability density function (PDF)
f (xi,μi,σi) = 1/( σi×sqrt(2π) ) e(xiμi)2 / 2σi2 ,  σi > 0 .
f (xi,μi,σi) = 1 σi2π e -(xi-μi)2/2σi2 ,  σi>0 .
The input arrays to this function are designed to allow maximum flexibility in the supply of vector parameters by re-using elements of any arrays that are shorter than the total number of evaluations required. See Section [Vectorized s] in the G01 Chapter Introduction for further information.

References

None.

Parameters

Compulsory Input Parameters

1:     ilog – int64int32nag_int scalar
The value of ilog determines whether the logarithmic value is returned in PDF.
ilog = 0ilog=0
f(xi,μi,σi)f(xi,μi,σi), the probability density function is returned.
ilog = 1ilog=1
log(f(xi,μi,σi))log(f(xi,μi,σi)), the logarithm of the probability density function is returned.
Constraint: ilog = 0ilog=0 or 11.
2:     x(lx) – double array
lx, the dimension of the array, must satisfy the constraint lx > 0lx>0.
xixi, the values at which the PDF is to be evaluated with xi = x(j)xi=xj, j = ((i1)  mod  lx) + 1j=((i-1) mod lx)+1, for i = 1,2,,max (lx,lxstd,lxmu)i=1,2,,max(lx,lxstd,lxmu).
3:     xmu(lxmu) – double array
lxmu, the dimension of the array, must satisfy the constraint lxmu > 0lxmu>0.
μiμi, the means with μi = xmu(j)μi=xmuj, j = ((i1)  mod  lxmu) + 1j=((i-1) mod lxmu)+1.
4:     xstd(lxstd) – double array
lxstd, the dimension of the array, must satisfy the constraint lxstd > 0lxstd>0.
σiσi, the standard deviations with σi = xstd(j)σi=xstdj, j = ((i1)  mod  lxstd) + 1j=((i-1) mod lxstd)+1.
Constraint: xstd(j)0.0xstdj0.0, for j = 1,2,,lxstdj=1,2,,lxstd.

Optional Input Parameters

1:     lx – int64int32nag_int scalar
Default: The dimension of the array x.
The length of the array x.
Constraint: lx > 0lx>0.
2:     lxmu – int64int32nag_int scalar
Default: The dimension of the array xmu.
The length of the array xmu.
Constraint: lxmu > 0lxmu>0.
3:     lxstd – int64int32nag_int scalar
Default: The dimension of the array xstd.
The length of the array xstd.
Constraint: lxstd > 0lxstd>0.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     pdf( : :) – double array
Note: the dimension of the array pdf must be at least max (lx,lxstd,lxmu)max(lx,lxstd,lxmu).
f(xi,μi,σi)f(xi,μi,σi) or log(f(xi,μi,σi))log(f(xi,μi,σi)).
2:     ivalid( : :) – int64int32nag_int array
Note: the dimension of the array ivalid must be at least max (lx,lxstd,lxmu)max(lx,lxstd,lxmu).
ivalid(i)ivalidi indicates any errors with the input arguments, with
ivalid(i) = 0ivalidi=0
No error.
ivalid(i) = 1ivalidi=1
σi < 0σi<0.
3:     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:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

W ifail = 1ifail=1
On entry, at least one value of xstd was invalid.
Check ivalid for more information.
  ifail = 2ifail=2
Constraint: ilog = 0ilog=0 or 11.
  ifail = 3ifail=3
Constraint: lx > 0lx>0.
  ifail = 4ifail=4
Constraint: lxmu > 0lxmu>0.
  ifail = 5ifail=5
Constraint: lxstd > 0lxstd>0.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_stat_pdf_normal_vector_example
x =     [1.0, 4.0, 0.1, 1.0];
xmean = [0.0, 2.0, 0.0, 0.0];
xstd =  [1.0, 1.0, 0.01, 10];
ilog = int64(0);
[pdf, ivalid, ifail] = nag_stat_pdf_normal_vector(ilog, x, xmean, xstd);

fprintf('\n  x             mean          standard      result\n');
fprintf('                              deviation\n');
lx     = numel(x);
lxmean = numel(xmean);
lxstd  = numel(xstd);
len = max ([lx, lxmean, lxstd]);
for i=0:len-1
 fprintf('%13.5e %13.5e %13.5e %13.5e %3d\n', x(mod(i,lx)+1), ...
         xmean(mod(i,lxmean)+1), xstd(mod(i,lxstd)+1), pdf(i+1), ivalid(i+1));
end
 

  x             mean          standard      result
                              deviation
  1.00000e+00   0.00000e+00   1.00000e+00   2.41971e-01   0
  4.00000e+00   2.00000e+00   1.00000e+00   5.39910e-02   0
  1.00000e-01   0.00000e+00   1.00000e-02   7.69460e-21   0
  1.00000e+00   0.00000e+00   1.00000e+01   3.96953e-02   0

function g01kq_example
x =     [1.0, 4.0, 0.1, 1.0];
xmean = [0.0, 2.0, 0.0, 0.0];
xstd =  [1.0, 1.0, 0.01, 10];
ilog = int64(0);
[pdf, ivalid, ifail] = g01kq(ilog, x, xmean, xstd);

fprintf('\n  x             mean          standard      result\n');
fprintf('                              deviation\n');
lx     = numel(x);
lxmean = numel(xmean);
lxstd  = numel(xstd);
len = max ([lx, lxmean, lxstd]);
for i=0:len-1
 fprintf('%13.5e %13.5e %13.5e %13.5e %3d\n', x(mod(i,lx)+1), ...
         xmean(mod(i,lxmean)+1), xstd(mod(i,lxstd)+1), pdf(i+1), ivalid(i+1));
end
 

  x             mean          standard      result
                              deviation
  1.00000e+00   0.00000e+00   1.00000e+00   2.41971e-01   0
  4.00000e+00   2.00000e+00   1.00000e+00   5.39910e-02   0
  1.00000e-01   0.00000e+00   1.00000e-02   7.69460e-21   0
  1.00000e+00   0.00000e+00   1.00000e+01   3.96953e-02   0


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