percentile

@JvmName(name = "percentileOfLong")
fun Iterable<Long>.percentile(p: Double, method: QuantileMethod = QuantileMethod.LINEAR): Double(source)

Computes the p-th percentile of the Long values.

Values are converted to Double internally. Long values whose absolute value exceeds 2^53 (9,007,199,254,740,992) may lose precision in the least-significant digits.

Example:

listOf(1L, 2L, 3L, 4L, 5L).percentile(50.0) // 3.0

Return

the p-th percentile of the Long values as a Double.

Parameters

p

the percentile to compute, in 0, 100.

method

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


@JvmName(name = "percentileOfInt")
fun Iterable<Int>.percentile(p: Double, method: QuantileMethod = QuantileMethod.LINEAR): Double(source)

Computes the p-th percentile of the Int values.

Values are converted to Double internally. The conversion is exact for all Int values.

Example:

listOf(1, 2, 3, 4, 5).percentile(50.0) // 3.0

Return

the p-th percentile of the Int values as a Double.

Parameters

p

the percentile to compute, in 0, 100.

method

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


fun Iterable<Double>.percentile(p: Double, method: QuantileMethod = QuantileMethod.LINEAR): Double(source)

Computes the p-th percentile of the values in this iterable.

The percentile indicates the value below which a given percentage of observations fall. For example, the 50th percentile is the median. Delegates to quantile after converting the percentile (0–100 scale) to a quantile (0–1 scale).

Example:

listOf(1.0, 2.0, 3.0, 4.0, 5.0).percentile(50.0) // 3.0
listOf(1.0, 2.0, 3.0, 4.0, 5.0).percentile(25.0, QuantileMethod.WEIBULL) // 1.5

Return

the p-th percentile value.

Parameters

p

the percentile to compute, in 0, 100.

method

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


fun DoubleArray.percentile(p: Double, method: QuantileMethod = QuantileMethod.LINEAR): Double(source)

Computes the p-th percentile of the values in this array.

The percentile indicates the value below which a given percentage of observations fall. For example, the 50th percentile is the median. Uses introselect (expected O(n) time) instead of a full sort.

Example:

doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0).percentile(50.0) // 3.0
doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0).percentile(25.0, QuantileMethod.WEIBULL) // 1.5

Return

the p-th percentile value.

Parameters

p

the percentile to compute, in 0, 100.

method

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


fun Sequence<Double>.percentile(p: Double, method: QuantileMethod = QuantileMethod.LINEAR): Double(source)

Computes the p-th percentile of the values in this sequence.

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

Return

the p-th percentile value.

Parameters

p

the percentile to compute, in 0, 100.

method

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


@JvmName(name = "percentileOfLongDeprecated")
fun Iterable<Long>.percentile(p: Double, interpolation: QuantileInterpolation): Double(source)

Deprecated

Use the overload with QuantileMethod instead.

Replace with

percentile(p, interpolation.toQuantileMethod())

Computes the p-th percentile of the Long values.

Values are converted to Double internally. Long values whose absolute value exceeds 2^53 (9,007,199,254,740,992) may lose precision in the least-significant digits.

Return

the p-th percentile of the Long values as a Double.

Parameters

p

the percentile to compute, in 0, 100.

interpolation

the interpolation mode.


@JvmName(name = "percentileOfIntDeprecated")
fun Iterable<Int>.percentile(p: Double, interpolation: QuantileInterpolation): Double(source)

Deprecated

Use the overload with QuantileMethod instead.

Replace with

percentile(p, interpolation.toQuantileMethod())

Computes the p-th percentile of the Int values.

Values are converted to Double internally. The conversion is exact for all Int values.

Return

the p-th percentile of the Int values as a Double.

Parameters

p

the percentile to compute, in 0, 100.

interpolation

the interpolation mode.


Deprecated

Use the overload with QuantileMethod instead.

Replace with

percentile(p, interpolation.toQuantileMethod())

Computes the p-th percentile of the values in this iterable.

Return

the p-th percentile value.

Parameters

p

the percentile to compute, in 0, 100.

interpolation

the interpolation mode.


Deprecated

Use the overload with QuantileMethod instead.

Replace with

percentile(p, interpolation.toQuantileMethod())

Computes the p-th percentile of the values in this array.

Return

the p-th percentile value.

Parameters

p

the percentile to compute, in 0, 100.

interpolation

the interpolation mode.


Deprecated

Use the overload with QuantileMethod instead.

Replace with

percentile(p, interpolation.toQuantileMethod())

Computes the p-th percentile of the values in this sequence.

Return

the p-th percentile value.

Parameters

p

the percentile to compute, in 0, 100.

interpolation

the interpolation mode.