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:
static void g01ad(
	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: 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 i is bounded by the values in x[i-1] and x[i], for i=1,2,,k-1.
Constraint: x[i]<x[i+1], for i=0,1,,k-2.
ifreq
Type: array<System..::..Int32>[]()[][]
An array of size [k]
On entry: the ith element of ifreq must contain the frequency associated with the ith class, for i=1,2,,k-1. ifreq[k-1] is not used by the method.
Constraints:
  • ifreq[i-1]0, for i=1,2,,k-1;
  • i=1k-1ifreq[i-1]>0.
xmean
Type: System..::..Double%
On exit: the mean value, y-.
s2
Type: System..::..Double%
On exit: the standard deviation, s2.
s3
Type: System..::..Double%
On exit: the coefficient of skewness, s3.
s4
Type: System..::..Double%
On exit: the coefficient of kurtosis, s4.
n
Type: System..::..Int32%
On exit: the total frequency, n.
ifail
Type: System..::..Int32%
On exit: 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 fi, for i=1,2,,k-1, and the boundary values of the classes xi, for i=1,2,,k. Thus the frequency associated with the interval xi,xi+1 is fi, 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,  n2.
(d) coefficient of skewness,
s3=i=1k-1fiyi-y-3n-1×s23,  n2.
(e) coefficient of kurtosis,
s4=i=1k-1fiyi-y-4n-1×s24-3,  n2.
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 y1,,yk-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.

References

None.

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry,k1.
ifail=2
On entry,the boundary values of the classes in x are not in ascending order.
ifail=3
On entry,i=1k-1ifreq[i-1]=0 or ifreq[i-1]<0 for some i, for i=1,2,,k-1.
ifail=4
The total frequency, n, is less than 2, hence the quantities s2, s3 and s4 cannot be calculated.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

The method used is believed to be stable.

Parallelism and Performance

None.

Further Comments

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.

Example program (C#): g01ade.cs

Example program data: g01ade.d

Example program results: g01ade.r

See Also