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
| Parameter | Type | Required | Description |
|---|---|---|---|
hashing_key | VARCHAR | Yes | String value to hash (typically user ID or session ID) |
rate | DOUBLE | Yes | Rate 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 |
On this page