percentiles

open fun <T : Number> Field<Into, List<T>>.percentiles(value: Value<From, Number?>, vararg percentiles: Double)(source)
open fun <T : Number> KProperty1<Into, List<T>>.percentiles(value: Value<From, Number?>, vararg percentiles: Double)(source)

Returns an approximation of the specified percentiles.

Each percentile is computed with the t-digest algorithm, which computes an approximation. The results may vary, even on the same dataset.

Example

class User(
val name: String,
val balance: Int,
)

class Result(
val percentiles: List<Double>,
)

users.aggregate()
.group {
Result::percentiles.percentiles(of(User::balance), 0.5, 0.75, 0.9, 0.95)
}

External resources