NAG Library Routine Document
g01aef
(frequency_table)
1
Purpose
g01aef constructs a frequency distribution of a variable, according to either user-supplied, or routine-calculated class boundary values.
2
Specification
Fortran Interface
Integer, Intent (In) | :: |
n,
k,
iclass | Integer, Intent (Inout) | :: |
ifail | Integer, Intent (Out) | :: |
ifreq(k) | Real (Kind=nag_wp), Intent (In) | :: |
x(n) | Real (Kind=nag_wp), Intent (Inout) | :: |
cb(k) | Real (Kind=nag_wp), Intent (Out) | :: |
xmin,
xmax |
|
C Header Interface
#include nagmk26.h
void |
g01aef_ (
const Integer *n,
const Integer *k,
const double x[],
const Integer *iclass,
double cb[],
Integer ifreq[],
double *xmin,
double *xmax,
Integer *ifail) |
|
3
Description
The data consists of a sample of observations of a continuous variable, denoted by , for . Let and .
g01aef constructs a frequency distribution with classes denoted by , for .
The boundary values may be either user-supplied, or routine-calculated, and are denoted by , for .
If the boundary values of the classes are to be routine-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 routine-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; routine-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: – IntegerInput
-
On entry: , the number of observations.
Constraint:
.
- 2: – IntegerInput
-
On entry:
, the number of classes desired in the frequency distribution. Whether or not class boundary values are user-supplied,
k must include the two extreme classes which stretch to
.
Constraint:
.
- 3: – Real (Kind=nag_wp) arrayInput
-
On entry: the sample of observations of the variable for which the frequency distribution is required,
, for . The values may be in any order.
- 4: – IntegerInput
-
On entry: indicates whether class boundary values are to be calculated within
g01aef, or are supplied by you.
If , the class boundary values are to be calculated within the routine.
If , they are user-supplied.
Constraint:
or .
- 5: – Real (Kind=nag_wp) arrayInput/Output
-
On entry: if
, the elements of
cb need not be assigned values, as
g01aef calculates
class boundary values.
If
, the first
elements of
cb must contain the class boundary values you supplied, in ascending order.
In both cases, the element need not be assigned, as it is not used in the routine.
On exit: the first
elements of
cb contain the class boundary values in ascending order.
Constraint:
if , , for .
- 6: – Integer arrayOutput
-
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: – Real (Kind=nag_wp)Output
-
On exit: the smallest value in the sample, .
- 8: – Real (Kind=nag_wp)Output
-
On exit: the largest value in the sample, .
- 9: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, and .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
The method used is believed to be stable.
8
Parallelism and Performance
g01aef is not threaded in any implementation.
The time taken by
g01aef increases with
k 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. g01aef is then called and the frequency distribution and largest and smallest observations printed.
10.1
Program Text
Program Text (g01aefe.f90)
10.2
Program Data
Program Data (g01aefe.d)
10.3
Program Results
Program Results (g01aefe.r)