Skip to main content
Skip to main content

quantilesDeterministic

quantilesDeterministic

Introduced in: v1.1.0

Computes multiple approximate quantiles of a numeric data sequence at different levels simultaneously, using deterministic reservoir sampling.

This function is equivalent to quantileDeterministic but allows computing multiple quantile levels in a single pass, which is more efficient than calling individual quantile functions.

Syntax

quantilesDeterministic(level1, level2, ...)(expr, determinator)

Parameters

  • level — Levels of quantiles. One or more constant floating-point numbers from 0 to 1. We recommend using level values in the range of [0.01, 0.99]. Float*

Arguments

  • expr — Expression over the column values resulting in numeric data types, Date or DateTime. (U)Int* or Int128 or UInt128 or Int256 or UInt256 or Float* or Date or DateTime
  • determinator — Number whose hash is used instead of a random number generator in the reservoir sampling algorithm to make the result of sampling deterministic. UInt*

Returned value

Array of approximate quantiles of the specified levels in the same order as the levels were specified. Array(Float64) or Array(Date) or Array(DateTime)

Examples

Computing multiple deterministic quantiles

SELECT quantilesDeterministic(0.25, 0.5, 0.75)(number, number) FROM numbers(10)
┌─quantilesDeterministic(0.25, 0.5, 0.75)(number, number)─┐
│ [2.25,4.5,6.75]                                         │
└─────────────────────────────────────────────────────────┘