Class WEIGHTED_RANDOM
Weighted random table calculators.
Class Overview
Methods
| WEIGHTED_RANDOM:New() | Create a new weighted random table instance. |
| WEIGHTED_RANDOM:Add(data[, weight]) | Add a new set of data, optionally with weight. |
| WEIGHTED_RANDOM:Random() | Pull out a random value from the table, respecting the weights of the table. |
- WEIGHTED_RANDOM:New()
-
Create a new weighted random table instance.
Returns:
-
WEIGHTED_RANDOM
- WEIGHTED_RANDOM:Add(data[, weight])
-
Add a new set of data, optionally with weight.
Parameters:
- data Any data. If a table, the .weight field is taken as the weight.
- weight int A manual override weight value. (optional)
Returns:
-
WEIGHTED_RANDOM
- WEIGHTED_RANDOM:Random()
-
Pull out a random value from the table, respecting the weights of the table.
Returns:
-
mixed
Value from the table.