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: n1.
x
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: the sample observations, xi, for i=1,2,,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.
iwt=0
Indicates no user-supplied weights.
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 iwt=1, the elements of wt must contain the weights associated with the observations, wi, for i=1,2,,n.
If iwt=0, the elements of wt need not be set.
On exit: if iwt=1, the elements of wt are unchanged.
If iwt=0, each element of wt will be assigned the value 1.0.
xmean
Type: System..::..Double%
On exit: the mean, x-.
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.
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 i=1nwi. This will be n if iwt was 0 on entry.
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 data consist of a single sample of n observations, denoted by xi, with corresponding weights, wi, for i=1,2,,n.
If no specific weighting is required, then each wi 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 wi>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 m2, and will be based on m-1 degrees of freedom. The other quantities are evaluated provided m1.

References

None.

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry,n<1.
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.
ifail=3
Either the number of valid cases is 0, or at least one weight is negative.
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 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

See Also