# naginterfaces.library.stat.frequency_​table¶

naginterfaces.library.stat.frequency_table(x, cb=None)[source]

frequency_table constructs a frequency distribution of a variable, according to either user-supplied, or function-calculated class boundary values.

For full information please refer to the NAG Library document for g01ae

https://www.nag.com/numeric/nl/nagdoc_28.4/flhtml/g01/g01aef.html

Parameters
xfloat, array-like, shape

The sample of observations of the variable for which the frequency distribution is required, , for . The values may be in any order.

cbNone or float, array-like, shape , optional

If , the elements of need not be assigned values, as frequency_table calculates class boundary values.

If , the first elements of 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 function.

Returns
cbfloat, ndarray, shape

The first elements of contain the class boundary values in ascending order.

ifreqint, ndarray, shape

The elements of 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 , .

xminfloat

The smallest value in the sample, .

xmaxfloat

The largest value in the sample, .

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

Notes

The data consists of a sample of observations of a continuous variable, denoted by , for . Let and .

frequency_table 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:

1. if , the range of values is divided into intervals of equal length, and two extreme intervals, defined by the class boundary values ;

2. 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.