PROBABILITY_TO_EVENT
All functions > BUSINESS_SIMULATIONS > PROBABILITY_TO_EVENT
Returns the discrete event (true or false) with the given probability based on the given hashing key.
Syntax
PROBABILITY_TO_EVENT(hashing_key: VARCHAR, probability: DOUBLE) → BOOLEAN
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
hashing_key | VARCHAR | Yes | String value to hash (typically user ID or session ID) |
probability | DOUBLE | Yes | Probability of TRUE result (between 0.0 and 1.0) |
Returns
BOOLEAN - Deterministic TRUE/FALSE based on probability threshold
Notes
- Deterministic - same key always produces same result
- Returns TRUE with given probability, FALSE otherwise
- Uses HASH01 internally compared against probability threshold
- Probability should be between 0.0 (never) and 1.0 (always)
- Useful for A/B testing, feature flags, random sampling
- Common for conversion simulations, user assignments