Generate from list
Generates a value from a given list
Evaluation
This expression evaluates to a function of the form:
(seed) -> any
The function is consistent with generator semantics of the Random Data step.
Processing
Given a seed value, the function returns an item pseudo-randomly selected from a list.
Settings
Name |
Type |
Description |
Items |
list |
The list to pick a random item from. |
Distribution |
any |
Distribution of generated values.
Available options are:
uniform all possible values are generated with about the same probability
prefer start values at the start of the specified range are generated more frequently
prefer middle values in the middle of the specified range are generated more frequently
prefer end values at the end of the specified range are generated more frequently
strongly prefer start values at the start of the specified range are generated much more frequently
strongly prefer middle values in the middle of the specified range are generated much more frequently
strongly prefer end values at the end of the specified range are generated much more frequently
Custom Distribution Support
Alternatively, a list of double values between 0.0 and 1.0 is accepted.
The double value at each index corresponds to the same index in the item list and specifies the probability that the corresponding item is chosen from the list.
For example: an item list of ["Alice", "Bob", "Charlie"] and a distribution list of [0.5, 0.4, 0.1] makes the names appear with the given probabilities.
The following rules apply:
- If the list of probabilities is shorter than the list of items, any remaining probability space is distributed equally among the remaining items.
- If the list of probabilities is longer than the list of items, an error is thrown.
- If the list of probabilities adds to less than
1.0 the difference corresponds to the probability of generating nil .
- If the list of probabilities adds to more than
1.0 the behavior of the generator is undefined.
|
Chance of nil |
double |
Probability in range of 0.0 to 1.0 that the generator will return nil instead of generating a value. |