SAMPLE_WEIBULL()

All functions > BUSINESS > SAMPLE_WEIBULL()

Returns a value drawn from a Weibull distribution based on the given hashing key.

Signatures

Returns: Deterministic non-negative value from Weibull distribution

SAMPLE_WEIBULL(hashing_key: VARCHAR, shape: DOUBLE, scale: DOUBLE) → DOUBLE
sql
ParameterTypeRequiredDescription
hashing_keyVARCHARYesString value to hash (typically user ID or session ID)
shapeDOUBLEYesShape parameter k (> 0). k<1: decreasing failure rate, k=1: exponential, k>1: increasing failure rate
scaleDOUBLEYesScale parameter λ (> 0). Related to the characteristic life of the process

Notes

  • Deterministic - same key always produces same value
  • Uses inverse CDF: scale * (-LN(U))^(1/shape)
  • Generalizes exponential distribution (shape=1 gives exponential with rate=1/scale)
  • shape < 1: decreasing hazard (infant mortality)
  • shape = 1: constant hazard (exponential)
  • shape > 1: increasing hazard (wear-out, aging)
  • Common for reliability engineering, survival analysis, churn modeling
  • Both parameters must be strictly positive

Examples

FeatureQL
SELECT
    f1 := ROUND(SAMPLE_WEIBULL('k', 2E0, 10E0), 4) -- Weibull draw with shape=2, scale=10 for a fixed key
;
Result
f1 VARCHAR
7.7277

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