NAG Library Function Document
nag_frequency_table (g01aec)
1 Purpose
nag_frequency_table (g01aec) constructs a frequency distribution of a variable, according to either user-supplied, or function-calculated class boundary values.
2 Specification
#include <nag.h> |
#include <nagg01.h> |
|
3 Description
The data consists of a sample of observations of a continuous variable, denoted by , for . Let and .
nag_frequency_table (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:
n – IntegerInput
On entry: , the number of observations.
Constraint:
.
- 2:
x[n] – const doubleInput
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:
num_class – IntegerInput
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:
classb – Nag_ClassBoundaryInput
On entry: indicates whether class boundary values are to be calculated within nag_frequency_table (g01aec), or are supplied by you.
If , then the class boundary values are to be calculated within the function.
If , they are user-supplied.
Constraint:
or .
- 5:
cint[num_class] – doubleInput/Output
On entry: if
, then the elements of
cint need not be assigned values, as nag_frequency_table (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:
ifreq[num_class] – IntegerOutput
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:
xmin – double *Output
On exit: the smallest value in the sample, .
- 8:
xmax – double *Output
On exit: the largest value in the sample, .
- 9:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
6 Error Indicators and Warnings
- 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.
- NE_NOT_STRICTLY_INCREASING
-
On entry, and .
Constraint: .
7 Accuracy
The method used is believed to be stable.
8 Parallelism and Performance
Not applicable.
The time taken by nag_frequency_table (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. nag_frequency_table (g01aec) is then called and the frequency distribution and largest and smallest observations printed.
10.1 Program Text
Program Text (g01aece.c)
10.2 Program Data
Program Data (g01aece.d)
10.3 Program Results
Program Results (g01aece.r)