SAMPLE_LOGNORMAL()
All functions > BUSINESS > SAMPLE_LOGNORMAL()
Returns a value drawn from a log-normal distribution, clamped to [lower, upper], based on the given hashing key.
Signatures
Returns: Deterministic value from log-normal distribution, clamped to [lower, upper]
SAMPLE_LOGNORMAL(hashing_key: VARCHAR, meanlog: DOUBLE, stdlog: 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) |
meanlog | DOUBLE | Yes | Mean of the underlying normal distribution (log scale) |
stdlog | DOUBLE | Yes | Standard deviation of the underlying normal distribution (log scale, > 0) |
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 EXP(SAMPLE_GAUSSIAN) internally
- Parameters are on the LOG scale (meanlog, stdlog), not the output scale
- Actual mean of distribution is exp(meanlog + stdlog^2/2)
- Output is always positive, right-skewed
- Results clamped to [lower, upper] bounds
- Common for modeling prices, durations, income, claim sizes
- stdlog must be strictly positive
Examples
FeatureQL
SELECT
f1 := ROUND(SAMPLE_LOGNORMAL('k', 0E0, 1E0, 0E0, 100E0), 4) -- Standard log-normal draw clamped to [0, 100] for a fixed key
;Result
| f1 VARCHAR |
|---|
| 1.4788 |
On this page