SAMPLE_EXPONENTIAL()

All functions > BUSINESS > SAMPLE_EXPONENTIAL()

Returns a value drawn from an exponential distribution with the given rate, based on the given hashing key.

Signatures

Returns: Deterministic value from exponential distribution (>= 0)

SAMPLE_EXPONENTIAL(hashing_key: VARCHAR, rate: DOUBLE) → DOUBLE
sql
ParameterTypeRequiredDescription
hashing_keyVARCHARYesString value to hash (typically user ID or session ID)
rateDOUBLEYesRate parameter λ (> 0). Mean of the distribution is 1/λ.

Notes

  • Deterministic - same key always produces same value
  • Uses inverse CDF transform: -ln(HASH01(key)) / rate
  • Mean of distribution is 1/rate, variance is 1/rate^2
  • Models inter-arrival times in Poisson processes
  • Common for queue simulation, time-between-events modeling
  • Rate must be strictly positive

Examples

FeatureQL
SELECT
    f1 := ROUND(SAMPLE_EXPONENTIAL('k', 0.5E0), 4) -- Exponential draw with rate 0.5 (mean 2.0) for a fixed key
;
Result
f1 VARCHAR
1.1943

Last update at: 2026/05/26 17:22:09