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
ParameterTypeRequiredDescription
hashing_keyVARCHARYesString value to hash (typically user ID or session ID)
meanDOUBLEYesMean of the normal distribution
stdevDOUBLEYesStandard deviation of the distribution
lowerDOUBLEYesLower bound (values clamped to this minimum)
upperDOUBLEYesUpper 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

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