PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_stat_summary_freq (g01ad)
Purpose
nag_stat_summary_freq (g01ad) calculates the mean, standard deviation and coefficients of skewness and kurtosis for data grouped in a frequency distribution.
Syntax
Description
The input data consist of a univariate frequency distribution, denoted by
, for
, and the boundary values of the classes
, for
. Thus the frequency associated with the interval
is
, and
nag_stat_summary_freq (g01ad) assumes that all the values in this interval are concentrated at the point
The following quantities are calculated:
(a) |
total frequency,
|
(b) |
mean,
|
(c) |
standard deviation,
|
(d) |
coefficient of skewness,
|
(e) |
coefficient of kurtosis,
|
The function has been developed primarily for groupings of a continuous variable. If, however, the function is to be used on the frequency distribution of a discrete variable, taking the values
, then the boundary values for the classes may be defined as follows:
(i) |
for ,
|
(ii) |
for ,
|
References
None.
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The elements of
x must contain the boundary values of the classes in ascending order, so that class
is bounded by the values in
and
, for
.
Constraint:
, for .
- 2:
– int64int32nag_int array
-
The
th element of
ifreq must contain the frequency associated with the
th class, for
.
is not used by the function.
Constraints:
- , for ;
- .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
x,
ifreq. (An error is raised if these dimensions are not equal.)
, the number of class boundaries, which is one more than the number of classes of the frequency distribution.
Constraint:
.
Output Parameters
- 1:
– double scalar
-
The mean value, .
- 2:
– double scalar
-
The standard deviation, .
- 3:
– double scalar
-
The coefficient of skewness, .
- 4:
– double scalar
-
The coefficient of kurtosis, .
- 5:
– int64int32nag_int scalar
-
The total frequency, .
- 6:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
-
-
On entry, | the boundary values of the classes in x are not in ascending order. |
-
-
On entry, | or for some , for . |
- W
-
The total frequency, , is less than , hence the quantities , and cannot be calculated.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The method used is believed to be stable.
Further Comments
The time taken by nag_stat_summary_freq (g01ad) increases linearly with .
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 nag_stat_summary_freq (g01ad) has been successfully called, the input data and calculated quantities are printed. In the example, there is one set of data, with classes.
Open in the MATLAB editor:
g01ad_example
function g01ad_example
fprintf('g01ad example results\n\n');
x = [ 9.3 12 14 16 18 ...
20 22 24 26 28 ...
30 32 34 36 39.7];
ifreq = [ 3 19 52 96 121 ...
115 86 70 49 31 ...
16 6 8 7 0];
ifreq = int64(ifreq);
[xmean, s2, s3, s4, n, ifail] = g01ad( ...
x, ifreq);
fprintf('Number of classes %7d\n\n',size(x,2)-1);
fprintf('%14s%20s\n', 'Class', 'Frequency');
fprintf('%9.2f%9.2f%15d\n',[x(1:end-1);x(2:end);ifreq(1:end-1)]);
fprintf('\n');
fprintf('Mean %10.4f\n',xmean);
fprintf('Std devn %10.4f\n',s2);
fprintf('Skewness %10.4f\n',s3);
fprintf('Kurtosis %10.4f\n',s4);
fprintf('Number of cases %5d\n',n);
g01ad example results
Number of classes 14
Class Frequency
9.00 12.00 3
12.00 14.00 19
14.00 16.00 52
16.00 18.00 96
18.00 20.00 121
20.00 22.00 115
22.00 24.00 86
24.00 26.00 70
26.00 28.00 49
28.00 30.00 31
30.00 32.00 16
32.00 34.00 6
34.00 36.00 8
36.00 40.00 7
Mean 21.4932
Std devn 4.9325
Skewness 0.7072
Kurtosis 0.5738
Number of cases 679
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015