NAG CL Interface
g01aec (frequency_table)
1
Purpose
g01aec constructs a frequency distribution of a variable, according to either user-supplied, or function-calculated class boundary values.
2
Specification
The function may be called by the names: g01aec, nag_stat_frequency_table or nag_frequency_table.
3
Description
The data consists of a sample of observations of a continuous variable, denoted by , for . Let and .
g01aec constructs a frequency distribution with classes denoted by , for .
The boundary values may be either user-supplied, or function-calculated, and are denoted by , for .
If the boundary values of the classes are to be function-calculated, then they are determined in one of the following ways:
-
(a)if , the range of values is divided into intervals of equal length, and two extreme intervals, defined by the class boundary values ;
-
(b)if , .
However formed, the values
are assumed to be in ascending order. The class frequencies are formed with
- the number of values in the interval
- the number of values in the interval ,
- the number of values in the interval ,
where [ means inclusive, and ) means exclusive. If the class boundary values are function-calculated and
, then
, and
and
are chosen so that
and
.
If a frequency distribution is required for a discrete variable, then it is suggested that you supply the class boundary values; function-calculated boundary values may be slightly imprecise (due to the adjustment of and outlined above) and cause values very close to a class boundary to be assigned to the wrong class.
4
References
None.
5
Arguments
-
1:
– Integer
Input
-
On entry: , the number of observations.
Constraint:
.
-
2:
– const double
Input
-
On entry: the sample of observations of the variable for which the frequency distribution is required,
, for . The values may be in any order.
-
3:
– Integer
Input
-
On entry:
, the number of classes desired in the frequency distribution. Whether or not class boundary values are user-supplied,
num_class must include the two extreme classes which stretch to
.
Constraint:
.
-
4:
– Nag_ClassBoundary
Input
-
On entry: indicates whether class boundary values are to be calculated within
g01aec, or are supplied by you.
If , the class boundary values are to be calculated within the function.
If , they are user-supplied.
Constraint:
or .
-
5:
– double
Input/Output
-
On entry: if
, the elements of
cint need not be assigned values, as
g01aec calculates
class boundary values.
If
, the first
elements of
cint must contain the class boundary values you supplied, in ascending order.
On exit: the first
elements of
cint contain the class boundary values in ascending order.
Constraint:
if , , for .
-
6:
– Integer
Output
-
On exit: the elements of
ifreq contain the frequencies in each class,
, for
. In particular
contains the frequency of the class up to
,
, and
contains the frequency of the class greater than
,
.
-
7:
– double *
Output
-
On exit: the smallest value in the sample, .
-
8:
– double *
Output
-
On exit: the largest value in the sample, .
-
9:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_INT_ARG_LT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
See
Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library CL Interface for further information.
- NE_NOT_STRICTLY_INCREASING
-
On entry, and .
Constraint: .
7
Accuracy
The method used is believed to be stable.
8
Parallelism and Performance
Background information to multithreading can be found in the
Multithreading documentation.
g01aec is not threaded in any implementation.
The time taken by
g01aec increases with
num_class and
n. It also depends on the distribution of the sample observations.
10
Example
This example summarises a number of datasets. For each dataset the sample observations and optionally class boundary values are read. g01aec is then called and the frequency distribution and largest and smallest observations printed.
10.1
Program Text
10.2
Program Data
10.3
Program Results