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


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


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..


[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_withdraw_summary_1var(x, 'n', n, 'wt', wt)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: wt is no longer an output parameter; output parameters were reordered


The data consist of a single sample of n observations, denoted by xi, with corresponding weights, wi, for i=1,2,,n.
If no specific weighting is required, then each wi is set to 1.
The quantities computed are:
(a) The sum of the weights
(b) Mean
x-=i= 1nwixiW.  
(c) Standard deviation
s2=i=1nwi xi-x- 2d,   where  d=W-i=1nwi2W.  
(d) Coefficient of skewness
s3=i= 1nwi xi-x- 3 d×s23 .  
(e) Coefficient of kurtosis
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>0, i.e., the number of valid observations. Suppose m observations are valid, then the quantities in (c), (d) and (e) will be computed if m2, and will be based on m-1 degrees of freedom. The other quantities are evaluated provided m1.




Compulsory Input Parameters

1:     xn – double array
The sample observations, xi, for i=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.)
n, the number of observations.
Constraint: n1.
2:     wtn – double array
If the user wishes to supply weights then the elements of wt must contain the weights associated with the observations, wi, for i=1,2,,n.

Output Parameters

1:     xmean – double scalar
The mean, x-.
2:     s2 – double scalar
The standard deviation, s2.
3:     s3 – double scalar
The coefficient of skewness, s3.
4:     s4 – double scalar
The coefficient of kurtosis, s4.
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, m; see (g) in Description above.
8:     wtsum – double scalar
The sum of the weights in the array wt, that is i=1nwi. This will be n if iwt was 0 on entry.
9:     ifail int64int32nag_int scalar
ifail=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.

On entry,n<1.
W  ifail=2
The number of valid cases, m, is 1. In this case, standard deviation and coefficients of skewness and of kurtosis cannot be calculated.
Either the number of valid cases is 0, or at least one weight is negative.
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


The method used is believed to be stable.

Further Comments

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


This example summarises an (optionally weighted) dataset and displays the results.
function g01aa_example

fprintf('g01aa example results\n\n');

% Data
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];
n = size(x,2);

% Get simple statistics of data
[xmean, s2, s3, s4, xmin, xmax, iwt, wtsum, ifail] = ...

fprintf('Number of cases    %7d\n',n);
fprintf('Data as input -\n');
fprintf('No. of valid cases %7d\n',iwt);
fprintf('Mean               %7.1f\n',xmean);
fprintf('Minimum            %7.1f\n',xmin);
fprintf('Maximum            %7.1f\n',xmax);
fprintf('Sum of weights     %7.1f\n',wtsum);
fprintf('Std devn           %7.1f\n',s2);
fprintf('Skewness           %7.1f\n',s3);
fprintf('Kurtosis           %7.1f\n',s4);

g01aa example results

Number of cases         24
Data as input -
       193.0       216.0       112.0       161.0        92.0
       140.0        38.0        33.0       279.0       249.0
       473.0       339.0        60.0       130.0        20.0
        50.0       257.0       284.0       447.0        52.0
        67.0        61.0       150.0      2200.0

No. of valid cases      24
Mean                 254.3
Minimum               20.0
Maximum             2200.0
Sum of weights        24.0
Std devn             433.5
Skewness               3.9
Kurtosis              14.7

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–2015