g01ad calculates the mean, standard deviation and coefficients of skewness and kurtosis for data grouped in a frequency distribution.

Syntax

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

Parameters

k
Type: System..::..Int32
On entry: $k$, the number of class boundaries, which is one more than the number of classes of the frequency distribution.
Constraint: ${\mathbf{k}}>1$.
x
Type: array<System..::..Double>[]()[][]
An array of size [k]
On entry: the elements of x must contain the boundary values of the classes in ascending order, so that class $\mathit{i}$ is bounded by the values in ${\mathbf{x}}\left[\mathit{i}-1\right]$ and ${\mathbf{x}}\left[\mathit{i}\right]$, for $\mathit{i}=1,2,\dots ,k-1$.
Constraint: ${\mathbf{x}}\left[\mathit{i}\right]<{\mathbf{x}}\left[\mathit{i}+1\right]$, for $\mathit{i}=0,1,\dots ,k-2$.
ifreq
Type: array<System..::..Int32>[]()[][]
An array of size [k]
On entry: the $\mathit{i}$th element of ifreq must contain the frequency associated with the $\mathit{i}$th class, for $\mathit{i}=1,2,\dots ,k-1$. ${\mathbf{ifreq}}\left[k-1\right]$ is not used by the method.
Constraints:
• ${\mathbf{ifreq}}\left[\mathit{i}-1\right]\ge 0$, for $\mathit{i}=1,2,\dots ,k-1$;
• $\sum _{i=1}^{k-1}{\mathbf{ifreq}}\left[i-1\right]>0$.
xmean
Type: System..::..Double%
On exit: the mean value, $\stackrel{-}{y}$.
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}$.
n
Type: System..::..Int32%
On exit: the total frequency, $n$.
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 input data consist of a univariate frequency distribution, denoted by ${f}_{i}$, for $\mathit{i}=1,2,\dots ,k-1$, and the boundary values of the classes ${x}_{i}$, for $\mathit{i}=1,2,\dots ,k$. Thus the frequency associated with the interval $\left({x}_{i},{x}_{i+1}\right)$ is ${f}_{i}$, and g01ad assumes that all the values in this interval are concentrated at the point
 $yi=xi+1+xi/2, i=1,2,…,k-1.$
The following quantities are calculated:
(a) total frequency,
 $n=∑i=1k-1fi.$
(b) mean,
 $y-=∑i=1k-1fiyin.$
(c) standard deviation,
 $s2=∑i=1k-1fiyi-y-2n-1, n≥2.$
(d) coefficient of skewness,
 $s3=∑i=1k-1fiyi-y-3n-1×s23, n≥2.$
(e) coefficient of kurtosis,
 $s4=∑i=1k-1fiyi-y-4n-1×s24-3, n≥2.$
The method has been developed primarily for groupings of a continuous variable. If, however, the method is to be used on the frequency distribution of a discrete variable, taking the values ${y}_{1},\dots ,{y}_{k-1}$, then the boundary values for the classes may be defined as follows:
(i) for $k>2$,
 $x1=3y1-y2/2xj=yj-1+yj/2,j=2,…,k-1xk=3yk-1-yk-2/2$
(ii) for $k=2$,
 $x1=y1-a and x2=y1+a for any ​a>0.$

None.

Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{k}}\le 1$.
${\mathbf{ifail}}=2$
 On entry, the boundary values of the classes in x are not in ascending order.
${\mathbf{ifail}}=3$
 On entry, $\sum _{i=1}^{k-1}{\mathbf{ifreq}}\left[i-1\right]=0$ or ${\mathbf{ifreq}}\left[i-1\right]<0$ for some $i$, for $i=1,2,\dots ,k-1$.
${\mathbf{ifail}}=4$
The total frequency, $n$, is less than $2$, hence the quantities ${s}_{2}$, ${s}_{3}$ and ${s}_{4}$ cannot be calculated.
${\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 g01ad increases linearly with $k$.

Example

In the example program, NPROB determines the number of sets of data to be analysed. For each analysis, the boundary values of the classes and the frequencies are read. After g01ad has been successfully called, the input data and calculated quantities are printed. In the example, there is one set of data, with $14$ classes.