SAMPLE_POISSON()
All functions > BUSINESS > SAMPLE_POISSON()
Returns an integer drawn from a Poisson distribution with the given rate, based on the given hashing key.
Signatures
Returns: Deterministic non-negative integer from Poisson distribution
SAMPLE_POISSON(hashing_key: VARCHAR, rate: DOUBLE) → BIGINT sql
| Parameter | Type | Required | Description |
|---|---|---|---|
hashing_key | VARCHAR | Yes | String value to hash (typically user ID or session ID) |
rate | DOUBLE | Yes | Rate parameter λ, from 0 to 100. Also the mean and variance of the distribution. |
Notes
- Deterministic - same key always produces same value
- Returns the smallest k with P(X <= k) > HASH01(key), the exact inverse CDF
- Output is a non-negative integer (count of events), with no cap
- Models event counts per interval (arrivals, defects, requests)
- Common for demand forecasting, queue depth simulation
- A NULL key or rate gives NULL; a rate of 0 gives 0
- A rate below 0 or above 100 raises an error at runtime
Availability
| Status | Backends |
|---|---|
| Not available | mysql |
Examples
FeatureQL
RETURN
-- Poisson draw with rate 5 for a fixed key
f1 := SAMPLE_POISSON('k', 5e0),
-- Poisson draw with rate 50 for the same key
f2 := SAMPLE_POISSON('k', 50e0),
-- A rate of 0 always gives 0
f3 := SAMPLE_POISSON('k', 0e0),
-- A NULL key gives NULL
f4 := SAMPLE_POISSON(NULL::VARCHAR, 5e0)
;Result
| f1 BIGINT | f2 BIGINT | f3 BIGINT | f4 BIGINT |
|---|---|---|---|
| 5 | 51 | 0 | NULL |
On this page