NAG Library Routine Document
g01atf
(summary_onevar)
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
Fortran Interface
Subroutine g01atf ( |
nb,
x,
iwt,
wt,
pn,
xmean,
xsd,
xskew,
xkurt,
xmin,
xmax,
rcomm,
ifail) |
Integer, Intent (In) | :: |
nb,
iwt | Integer, Intent (Inout) | :: |
pn,
ifail | Real (Kind=nag_wp), Intent (In) | :: |
x(nb),
wt(*) | Real (Kind=nag_wp), Intent (Inout) | :: |
rcomm(20) | Real (Kind=nag_wp), Intent (Out) | :: |
xmean,
xsd,
xskew,
xkurt,
xmin,
xmax |
|
C Header Interface
#include nagmk26.h
void |
g01atf_ (
const Integer *nb,
const double x[],
const Integer *iwt,
const double wt[],
Integer *pn,
double *xmean,
double *xsd,
double *xskew,
double *xkurt,
double *xmin,
double *xmax,
double rcomm[],
Integer *ifail) |
|
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
Arguments
- 1: – 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: – 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: – 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: – 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: – 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: – Real (Kind=nag_wp)Output
-
On exit: , the mean of the first observations.
- 7: – Real (Kind=nag_wp)Output
-
On exit: , the standard deviation of the first observations.
- 8: – Real (Kind=nag_wp)Output
-
On exit: , the coefficient of skewness for the first observations.
- 9: – Real (Kind=nag_wp)Output
-
On exit: , the coefficient of kurtosis for the first observations.
- 10: – Real (Kind=nag_wp)Output
-
On exit: the smallest value in the first observations.
- 11: – Real (Kind=nag_wp)Output
-
On exit: the largest value in the first observations.
- 12: – 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: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
Not applicable.
8
Parallelism and Performance
g01atf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
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.
10
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.
10.1
Program Text
Program Text (g01atfe.f90)
10.2
Program Data
Program Data (g01atfe.d)
10.3
Program Results
Program Results (g01atfe.r)