NAG Library Routine Document
G01ATF
Note: before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.
1 Purpose
G01ATF calculates the mean, standard deviation, coefficients of skewness and kurtosis, and the maximum and minimum values for a set of (optionally weighted) data. The input data can be split into arbitrary sized blocks, allowing large datasets to be summarised.
2 Specification
SUBROUTINE G01ATF (
NB,
X,
IWT,
WT,
PN,
XMEAN,
XSD,
XSKEW,
XKURT,
XMIN,
XMAX,
RCOMM,
IFAIL)
INTEGER
NB, IWT, PN, IFAIL
REAL (KIND=nag_wp)
X(NB), WT(*), XMEAN, XSD, XSKEW, XKURT, XMIN, XMAX, RCOMM(20)
3 Description
Given a sample of
observations, denoted by
and a set of non-negative weights,
, G01ATF calculates a number of quantities:
(a)
Mean
(b)
Standard deviation
(c)
Coefficient of skewness
(d)
Coefficient of kurtosis
(e)
Maximum and minimum elements, with .
These quantities are calculated using the one pass algorithm of
West (1979).
For large datasets, or where all the data is not available at the same time, and can be split into arbitrary sized blocks and G01ATF called multiple times.
4 References
West D H D (1979) Updating mean and variance estimates: An improved method Comm. ACM 22 532–555
5 Parameters
- 1: NB – INTEGERInput
On entry:
, the number of observations in the current block of data. The size of the block of data supplied in
X and
WT can vary; therefore
NB can change between calls to G01ATF.
Constraint:
.
- 2: X(NB) – REAL (KIND=nag_wp) arrayInput
On entry: the current block of observations, corresponding to
, for , where is the number of observations processed so far and is the size of the current block of data.
- 3: IWT – INTEGERInput
On entry: indicates whether user-supplied weights are provided:
- User-supplied weights are given in the array WT.
- , for all , so no user-supplied weights are given and WT is not referenced.
Constraint:
or .
- 4: WT() – REAL (KIND=nag_wp) arrayInput
-
Note: the dimension of the array
WT
must be at least
if
.
On entry: if
,
WT must contain the user-supplied weights corresponding to the block of data supplied in
X, that is
, for
.
Constraint:
if , , for .
- 5: PN – INTEGERInput/Output
On entry: the number of valid observations processed so far, that is the number of observations with
, for
. On the first call to G01ATF, or when starting to summarise a new dataset,
PN must be set to
.
If , it must be the same value as returned by the last call to G01ATF.
On exit: the updated number of valid observations processed, that is the number of observations with
, for .
Constraint:
.
- 6: XMEAN – REAL (KIND=nag_wp)Output
On exit: , the mean of the first observations.
- 7: XSD – REAL (KIND=nag_wp)Output
On exit: , the standard deviation of the first observations.
- 8: XSKEW – REAL (KIND=nag_wp)Output
On exit: , the coefficient of skewness for the first observations.
- 9: XKURT – REAL (KIND=nag_wp)Output
On exit: , the coefficient of kurtosis for the first observations.
- 10: XMIN – REAL (KIND=nag_wp)Output
On exit: the smallest value in the first observations.
- 11: XMAX – REAL (KIND=nag_wp)Output
On exit: the largest value in the first observations.
- 12: RCOMM() – REAL (KIND=nag_wp) arrayCommunication Array
On entry: communication array, used to store information between calls to G01ATF. If
,
RCOMM need not be initialized, otherwise it must be unchanged since the last call to this routine.
On exit: the updated communication array. The first five elements of
RCOMM hold information that may be of interest with
the remaining elements of
RCOMM are used for workspace and so are undefined.
- 13: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, .
Constraint: or .
-
On entry, .
Constraint: if then , for .
-
On entry, .
Constraint: .
-
On entry,
.
On exit from previous call,
.
Constraint: if
,
PN must be unchanged since previous call.
-
On entry, the number of valid observations is zero.
-
On exit we were unable to calculate
XSKEW or
XKURT. A value of
has been returned.
-
On exit we were unable to calculate
XSD,
XSKEW or
XKURT. A value of
has been returned.
-
RCOMM has been corrupted between calls.
7 Accuracy
Not applicable.
Both G01ATF and
G01AUF consolidate results from multiple summaries. Whereas the former can only be used to combine summaries calculated sequentially, the latter combines summaries calculated in an arbitrary order allowing, for example, summaries calculated on different processing units to be combined.
9 Example
This example summarises some simulated data. The data is supplied in three blocks, the first consisting of observations, the second observations and the last observations.
9.1 Program Text
Program Text (g01atfe.f90)
9.2 Program Data
Program Data (g01atfe.d)
9.3 Program Results
Program Results (g01atfe.r)