quantile

fun Iterable<Double>.quantile(q: Double, method: QuantileMethod = QuantileMethod.LINEAR): Double(source)

Computes the q-th quantile of the values in this iterable.

The quantile at q is the value below which a fraction q of the data falls. For example, quantile(0.5) is the median. The estimation method determines how positions between data points are handled — see QuantileMethod for the nine standard Hyndman and Fan methods.

Example:

listOf(1.0, 2.0, 3.0, 4.0, 5.0).quantile(0.5)  // 3.0
listOf(1.0, 2.0, 3.0, 4.0, 5.0).quantile(0.25, QuantileMethod.MEDIAN_UNBIASED) // 1.75

Return

the q-th quantile value.

Parameters

q

the quantile to compute, in 0, 1.

method

the quantile estimation method. Defaults to QuantileMethod.LINEAR (HF7).


fun DoubleArray.quantile(q: Double, method: QuantileMethod = QuantileMethod.LINEAR): Double(source)

Computes the q-th quantile of the values in this array.

The quantile at q is the value below which a fraction q of the data falls. For example, quantile(0.5) is the median. Uses introselect (expected O(n) time) instead of a full sort. The estimation method determines how positions between data points are handled — see QuantileMethod for the nine standard Hyndman and Fan methods.

Example:

doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0).quantile(0.5)  // 3.0
doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0).quantile(0.25, QuantileMethod.MEDIAN_UNBIASED) // 1.75

Return

the q-th quantile value.

Parameters

q

the quantile to compute, in 0, 1.

method

the quantile estimation method. Defaults to QuantileMethod.LINEAR (HF7).


fun Sequence<Double>.quantile(q: Double, method: QuantileMethod = QuantileMethod.LINEAR): Double(source)

Computes the q-th quantile of the values in this sequence.

The sequence is materialized internally. See DoubleArray.quantile for details.

Return

the q-th quantile value.

Parameters

q

the quantile to compute, in 0, 1.

method

the quantile estimation method. Defaults to QuantileMethod.LINEAR (HF7).


Deprecated

Use the overload with QuantileMethod instead.

Replace with

quantile(q, interpolation.toQuantileMethod())

Computes the q-th quantile of the values in this iterable.

Return

the q-th quantile value.

Parameters

q

the quantile to compute, in 0, 1.

interpolation

the interpolation mode.


Deprecated

Use the overload with QuantileMethod instead.

Replace with

quantile(q, interpolation.toQuantileMethod())

Computes the q-th quantile of the values in this array.

Return

the q-th quantile value.

Parameters

q

the quantile to compute, in 0, 1.

interpolation

the interpolation mode.


Deprecated

Use the overload with QuantileMethod instead.

Replace with

quantile(q, interpolation.toQuantileMethod())

Computes the q-th quantile of the values in this sequence.

Return

the q-th quantile value.

Parameters

q

the quantile to compute, in 0, 1.

interpolation

the interpolation mode.