Category: Helper Functions

syRandomDiscrete

Returns random value according to discrete distribution. A new random value is returned every time the worksheet is calculated.

## Syntax

`syRandomDiscrete(Values, Probabilities)`

The syRandomDiscrete function syntax has the following arguments:

- Values: required. Range or array of possible values.
- Probabilities: required. Range or array of probabilities corresponding to given values.

Return value is the value generated according to the discrete distribution and given arguments.

## Remarks

Values argument represents all possible outcomes. If Probabilities argument doesn't have all of the corresponding values, then the first value from Values which does not have adjanced probability is taken as the last possible outcome, and the "remaining" probability is assigned to it (remaining probability in a sense that the sum of given probabilities should be 1). Both arguments should have at least two values.

## Examples

`=syRandomDiscrete({1,2,3},{0.5,0.3})`

- The function draws outcomes from 1, 2 and 3. Because the probability for 3 is missing, function assumes that it has a remaining probability of 0.2 (1 - 0.5 - 0.3 = 0.2).`=syRandomDiscrete({1,2,3,4},{0.5,0.3})`

- The function draws outcomes from 1, 2 and 3. Because the probability for 3 and 4 is missing, it takes the first outcome value without corresponding probability (3) and assumes that it has remaining probability of 0.2 (1 - 0.5 - 0.3 = 0.2).