# NAG Library Routine Document

## 1Purpose

g01auf combines sets of summaries produced by g01atf.

## 2Specification

Fortran Interface
 Subroutine g01auf ( b, pn, xsd, xmin, xmax,
 Integer, Intent (In) :: b Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: pn Real (Kind=nag_wp), Intent (In) :: mrcomm(20,b) Real (Kind=nag_wp), Intent (Out) :: xmean, xsd, xskew, xkurt, xmin, xmax, rcomm(20)
#include nagmk26.h
 void g01auf_ (const Integer *b, const double mrcomm[], Integer *pn, double *xmean, double *xsd, double *xskew, double *xkurt, double *xmin, double *xmax, double rcomm[], Integer *ifail)

## 3Description

Assume a dataset containing $n$ observations, denoted by $x=\left\{{x}_{i}:i=1,2,\dots ,n\right\}$ and a set of weights, $w=\left\{{w}_{i}:i=1,2,\dots ,n\right\}$, has been split into $b$ blocks, and each block summarised via a call to g01atf. Then g01auf takes the $b$ communication arrays returned by g01atf and returns the mean ($\stackrel{-}{x}$), standard deviation (${s}_{2}$), coefficients of skewness (${s}_{3}$) and kurtosis (${s}_{4}$), and the maximum and minimum values for the whole dataset.
For a definition of $\stackrel{-}{x},{s}_{2},{s}_{3}$ and ${s}_{4}$ see Section 3 in g01atf.

## 4References

West D H D (1979) Updating mean and variance estimates: An improved method Comm. ACM 22 532–555

## 5Arguments

1:     $\mathbf{b}$ – IntegerInput
On entry: $b$, the number of blocks the full dataset was split into.
Constraint: ${\mathbf{b}}\ge 1$.
2:     $\mathbf{mrcomm}\left(20,{\mathbf{b}}\right)$ – Real (Kind=nag_wp) arrayCommunication Array
On entry: the $j$th column of mrcomm must contain the information returned in rcomm from one of the runs of g01atf.
3:     $\mathbf{pn}$ – IntegerOutput
On exit: the number of valid observations, that is the number of observations with ${w}_{i}>0$, for $\mathit{i}=1,2,\dots ,n$.
4:     $\mathbf{xmean}$ – Real (Kind=nag_wp)Output
On exit: $\stackrel{-}{x}$, the mean.
5:     $\mathbf{xsd}$ – Real (Kind=nag_wp)Output
On exit: ${s}_{2}$, the standard deviation.
6:     $\mathbf{xskew}$ – Real (Kind=nag_wp)Output
On exit: ${s}_{3}$, the coefficient of skewness.
7:     $\mathbf{xkurt}$ – Real (Kind=nag_wp)Output
On exit: ${s}_{4}$, the coefficient of kurtosis.
8:     $\mathbf{xmin}$ – Real (Kind=nag_wp)Output
On exit: the smallest value.
9:     $\mathbf{xmax}$ – Real (Kind=nag_wp)Output
On exit: the largest value.
10:   $\mathbf{rcomm}\left(20\right)$ – Real (Kind=nag_wp) arrayCommunication Array
On exit: an amalgamation of the information held in mrcomm. This is in the same format as rcomm from g01atf.
11:   $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ or ​}1$. 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 $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=11$
On entry, ${\mathbf{b}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{b}}\ge 1$.
${\mathbf{ifail}}=21$
On entry, mrcomm is not in the expected format.
${\mathbf{ifail}}=31$
On entry, the number of valid observations is zero.
${\mathbf{ifail}}=51$
On exit we were unable to calculate xskew or xkurt. A value of $0$ has been returned.
${\mathbf{ifail}}=52$
On exit we were unable to calculate xsd, xskew or xkurt. A value of $0$ has been returned.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

Not applicable.

## 8Parallelism and Performance

g01auf is not threaded in any implementation.

The order that the $b$ communication arrays are stored in mrcomm is arbitrary. Different orders can lead to slightly different results due to numerical accuracy of floating-point calculations.
Both g01auf and g01atf 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.

## 10Example

This example summarises some simulated data. The data is supplied in three blocks, the first consisting of $21$ observations, the second $51$ observations and the last $28$ observations. Summaries are produced for each block of data separately and then an overall summary is produced.

### 10.1Program Text

Program Text (g01aufe.f90)

### 10.2Program Data

Program Data (g01aufe.d)

### 10.3Program Results

Program Results (g01aufe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017