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_summary_1var (g01aa)

Purpose

nag_stat_summary_1var (g01aa) calculates the mean, standard deviation, coefficients of skewness and kurtosis, and the maximum and minimum values for a set of ungrouped data. Weighting may be used.
Note: this function is scheduled to be withdrawn, please see g01aa in Advice on Replacement Calls for Withdrawn/Superseded Routines..

Syntax

[xmean, s2, s3, s4, xmin, xmax, iwt, wtsum, ifail] = g01aa(x, 'n', n, 'wt', wt)
[xmean, s2, s3, s4, xmin, xmax, iwt, wtsum, ifail] = nag_stat_summary_1var(x, 'n', n, 'wt', wt)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: wt no longer an output parameter, output parameters re-ordered
.

Description

The data consist of a single sample of nn observations, denoted by xixi, with corresponding weights, wiwi, for i = 1,2,,ni=1,2,,n.
If no specific weighting is required, then each wiwi is set to 11.
The quantities computed are:
(a) The sum of the weights
n
W = wi.
i = 1
W=i=1nwi.
(b) Mean
x = (i = 1nwixi)/W.
x-=i= 1nwixiW.
(c) Standard deviation
s2 = sqrt((i = 1nwi(xix)2)/d),   where  d = W(i = 1nwi2)/W.
s2=i=1nwi (xi-x-) 2d,   where  d=W-i=1nwi2W.
(d) Coefficient of skewness
s3 = (i = 1nwi(xix)3)/(d × s23).
s3=i= 1nwi (xi-x-) 3 d×s23 .
(e) Coefficient of kurtosis
s4 = (i = 1nwi(xix)4)/(d × s24)3.
s4=i=1nwi (xi-x-) 4 d×s24 -3.
(f) Maximum and minimum elements of the sample.
(g) The number of observations for which wi > 0wi>0, i.e., the number of valid observations. Suppose mm observations are valid, then the quantities in (c), (d) and (e) will be computed if m2m2, and will be based on m1m-1 degrees of freedom. The other quantities are evaluated provided m1m1.

References

None.

Parameters

Compulsory Input Parameters

1:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n1n1.
The sample observations, xixi, for i = 1,2,,ni=1,2,,n.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the arrays x, wt. (An error is raised if these dimensions are not equal.)
nn, the number of observations.
Constraint: n1n1.
2:     wt(n) – double array
If the user wishes to supply weights then the elements of wt must contain the weights associated with the observations, wiwi, for i = 1,2,,ni=1,2,,n.

Input Parameters Omitted from the MATLAB Interface

iwt

Output Parameters

1:     xmean – double scalar
The mean, xx-.
2:     s2 – double scalar
The standard deviation, s2s2.
3:     s3 – double scalar
The coefficient of skewness, s3s3.
4:     s4 – double scalar
The coefficient of kurtosis, s4s4.
5:     xmin – double scalar
The smallest value in the sample.
6:     xmax – double scalar
The largest value in the sample.
7:     iwt – int64int32nag_int scalar
iwt is used to indicate the number of valid observations, mm; see (g) in Section [Description] above.
8:     wtsum – double scalar
The sum of the weights in the array wt, that is i = 1nwii=1nwi. This will be n if iwt was 00 on entry.
9:     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.

  ifail = 1ifail=1
On entry,n < 1n<1.
W ifail = 2ifail=2
The number of valid cases, mm, is 11. In this case, standard deviation and coefficients of skewness and of kurtosis cannot be calculated.
  ifail = 3ifail=3
Either the number of valid cases is 00, or at least one weight is negative.

Accuracy

The method used is believed to be stable.

Further Comments

The time taken by nag_stat_summary_1var (g01aa) is approximately proportional to nn.

Example

function nag_stat_summary_1var_example
x = [193;
     216;
     112;
     161;
     92;
     140;
     38;
     33;
     279;
     249;
     473;
     339;
     60;
     130;
     20;
     50;
     257;
     284;
     447;
     52;
     67;
     61;
     150;
     2200];
[xmean, s2, s3, s4, xmin, xmax, iwt, wtsum, ifail] = nag_stat_summary_1var(x)
 

xmean =

  254.2917


s2 =

  433.5318


s3 =

    3.8951


s4 =

   14.6653


xmin =

    20


xmax =

        2200


iwt =

                   24


wtsum =

    24


ifail =

                    0


function g01aa_example
x = [193;
     216;
     112;
     161;
     92;
     140;
     38;
     33;
     279;
     249;
     473;
     339;
     60;
     130;
     20;
     50;
     257;
     284;
     447;
     52;
     67;
     61;
     150;
     2200];
[xmean, s2, s3, s4, xmin, xmax, iwt, wtsum, ifail] = g01aa(x)
 

xmean =

  254.2917


s2 =

  433.5318


s3 =

    3.8951


s4 =

   14.6653


xmin =

    20


xmax =

        2200


iwt =

                   24


wtsum =

    24


ifail =

                    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