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.

# Syntax

C#
```public static void g01aa(
int n,
double[] x,
ref int iwt,
double[] wt,
out double xmean,
out double s2,
out double s3,
out double s4,
out double xmin,
out double xmax,
out double wtsum,
out int ifail
)```
Visual Basic
```Public Shared Sub g01aa ( _
n As Integer, _
x As Double(), _
ByRef iwt As Integer, _
wt As Double(), _
<OutAttribute> ByRef xmean As Double, _
<OutAttribute> ByRef s2 As Double, _
<OutAttribute> ByRef s3 As Double, _
<OutAttribute> ByRef s4 As Double, _
<OutAttribute> ByRef xmin As Double, _
<OutAttribute> ByRef xmax As Double, _
<OutAttribute> ByRef wtsum As Double, _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g01aa(
int n,
array<double>^ x,
int% iwt,
array<double>^ wt,
[OutAttribute] double% xmean,
[OutAttribute] double% s2,
[OutAttribute] double% s3,
[OutAttribute] double% s4,
[OutAttribute] double% xmin,
[OutAttribute] double% xmax,
[OutAttribute] double% wtsum,
[OutAttribute] int% ifail
)```
F#
```static member g01aa :
n : int *
x : float[] *
iwt : int byref *
wt : float[] *
xmean : float byref *
s2 : float byref *
s3 : float byref *
s4 : float byref *
xmin : float byref *
xmax : float byref *
wtsum : float byref *
ifail : int byref -> unit
```

#### Parameters

n
Type: System..::..Int32
On entry: $n$, the number of observations.
Constraint: ${\mathbf{n}}\ge 1$.
x
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: the sample observations, ${x}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
iwt
Type: System..::..Int32%
On entry: indicates whether weights are to be supplied by you or not. In the latter case, the weights will be assumed equal and assigned the value $1.0$ in the method.
${\mathbf{iwt}}=0$
Indicates no user-supplied weights.
${\mathbf{iwt}}=1$
Indicates user-supplied weights are required, and they will be supplied in the array wt.
On exit: iwt is used to indicate the number of valid observations, $m$; see (g) in [Description] above.
wt
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: if ${\mathbf{iwt}}=1$, the elements of wt must contain the weights associated with the observations, ${w}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
If ${\mathbf{iwt}}=0$, the elements of wt need not be set.
On exit: if ${\mathbf{iwt}}=1$, the elements of wt are unchanged.
If ${\mathbf{iwt}}=0$, each element of wt will be assigned the value $1.0$.
xmean
Type: System..::..Double%
On exit: the mean, $\stackrel{-}{x}$.
s2
Type: System..::..Double%
On exit: the standard deviation, ${s}_{2}$.
s3
Type: System..::..Double%
On exit: the coefficient of skewness, ${s}_{3}$.
s4
Type: System..::..Double%
On exit: the coefficient of kurtosis, ${s}_{4}$.
xmin
Type: System..::..Double%
On exit: the smallest value in the sample.
xmax
Type: System..::..Double%
On exit: the largest value in the sample.
wtsum
Type: System..::..Double%
On exit: the sum of the weights in the array wt, that is $\sum _{i=1}^{n}{w}_{i}$. This will be n if iwt was $0$ on entry.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

The data consist of a single sample of $n$ observations, denoted by ${x}_{i}$, with corresponding weights, ${w}_{i}$, for $\mathit{i}=1,2,\dots ,n$.
If no specific weighting is required, then each ${w}_{i}$ is set to $1$.
The quantities computed are:
(a) The sum of the weights
 $W=∑i=1nwi.$
(b) Mean
 $x-=∑i=1nwixiW.$
(c) Standard deviation
 $s2=∑i=1nwixi-x-2d, where d=W-∑i=1nwi2W.$
(d) Coefficient of skewness
 $s3=∑i=1nwixi-x-3d×s23.$
(e) Coefficient of kurtosis
 $s4=∑i=1nwixi-x-4d×s24-3.$
(f) Maximum and minimum elements of the sample.
(g) The number of observations for which ${w}_{i}>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 $m\ge 2$, and will be based on $m-1$ degrees of freedom. The other quantities are evaluated provided $m\ge 1$.

None.

# Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{n}}<1$.
${\mathbf{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.
${\mathbf{ifail}}=3$
Either the number of valid cases is $0$, or at least one weight is negative.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# Accuracy

The method used is believed to be stable.

# Parallelism and Performance

None.

The time taken by g01aa is approximately proportional to $n$.

# Example

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

Example program (C#): g01aae.cs

Example program data: g01aae.d

Example program results: g01aae.r