SAMPLE_GAUSSIAN()
All functions > BUSINESS > SAMPLE_GAUSSIAN()
Returns a value chosen from a normal distribution between two bounds based on the given hashing key.
Signatures
Returns: Deterministic value from normal distribution, clamped to [lower, upper]
SAMPLE_GAUSSIAN(hashing_key: VARCHAR, mean: DOUBLE, stdev: DOUBLE, lower: DOUBLE, upper: DOUBLE) → DOUBLE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
hashing_key | VARCHAR | Yes | String value to hash (typically user ID or session ID) |
mean | DOUBLE | Yes | Mean of the normal distribution |
stdev | DOUBLE | Yes | Standard deviation of the distribution |
lower | DOUBLE | Yes | Lower bound (values clamped to this minimum) |
upper | DOUBLE | Yes | Upper bound (values clamped to this maximum) |
Notes
- Deterministic - same key always produces same value
- Uses Box-Muller transform to generate normal distribution
- Values follow Gaussian/bell curve centered at mean
- Results clamped to [lower, upper] bounds
- Useful for realistic simulations with natural variation
- Common for modeling human behavior, response times, usage patterns
Examples
FeatureQL
SELECT
f1 := ROUND(SAMPLE_GAUSSIAN('k', 10E0, 2E0, 5E0, 15E0), 4) -- Clamped Gaussian draw, rounded for a stable doc value
;Result
| f1 VARCHAR |
|---|
| 10.7825 |
On this page