naginterfaces.library.stat.quantiles_​stream_​fixed

naginterfaces.library.stat.quantiles_stream_fixed(ind, n, rv, nb, eps, q, nq, rcomm, icomm)[source]

quantiles_stream_fixed finds approximate quantiles from a data stream of known size using an out-of-core algorithm.

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

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

Parameters
indint

Indicates the action required in the current call to quantiles_stream_fixed.

Return the required length of and in and respectively. and must be set and must be at least .

Initialise the communication arrays and process the first values from the data stream as supplied in .

Process the next block of values from the data stream. The calling program must update and (if required) , and re-enter quantiles_stream_fixed with all other parameters unchanged.

Calculate the -approximate quantiles specified in . The calling program must set and and re-enter quantiles_stream_fixed with all other parameters unchanged. This option can be chosen only when .

nint

, the total number of values in the data stream.

rvfloat, array-like, shape

Note: the required length for this argument is determined as follows: if : ; otherwise: .

If or , the vector containing the current block of data, otherwise is not referenced.

nbint

If or , the size of the current block of data. The size of blocks of data in array can vary;, therefore, can change between calls to quantiles_stream_fixed.

epsfloat

Approximation factor .

qfloat, array-like, shape

Note: the required length for this argument is determined as follows: if : ; otherwise: .

If , the quantiles to be calculated, otherwise is not referenced. Note that , corresponds to the minimum value and to the maximum value.

nqint

If , the number of quantiles requested, otherwise is not referenced.

rcommfloat, ndarray, shape , modified in place

Note: the required length for this argument is determined as follows: if : the value returned in by a call to quantiles_stream_fixed with ; otherwise: .

Communication array.

icommint, ndarray, shape , modified in place

Note: the required length for this argument is determined as follows: if : the value returned in by a call to quantiles_stream_fixed with ; otherwise: .

Communication array.

Returns
indint

Indicates output from a successful call.

Lengths of and have been returned in and respectively.

quantiles_stream_fixed has processed data points and expects to be called again with additional data (i.e., ).

quantiles_stream_fixed has returned the requested -approximate quantiles in . These quantiles are based on data points.

Routine has processed all data points (i.e., ).

npint

The number of elements processed so far.

qvfloat, ndarray, shape

If , contains the -approximate quantiles specified by the value provided in .

Raises
NagValueError
(errno )

On entry, .

Constraint: , , or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, or and .

Constraint: if or then .

(errno )

Number of data elements streamed, is not sufficient for a quantile query when .

Supply more data or reprocess the data with a higher value.

(errno )

On entry, and .

Constraint: if then .

(errno )

On entry, and .

Constraint: if then for all .

Notes

A quantile is a value which divides a frequency distribution such that there is a given proportion of data values below the quantile. For example, the median of a dataset is the quantile because half the values are less than or equal to it.

quantiles_stream_fixed uses a slightly modified version of an algorithm described in a paper by Zhang and Wang (2007) to determine -approximate quantiles of a data stream of real values, where is known. Given any quantile , an -approximate quantile is defined as an element in the data stream whose rank falls within . In case of more than one -approximate quantile being available, the one closest to is returned.

References

Zhang, Q and Wang, W, 2007, A fast algorithm for approximate quantiles in high speed data streams, Proceedings of the 19th International Conference on Scientific and Statistical Database Management, IEEE Computer Society, 29