BIS_fnc_selectRandomWeighted
Jump to navigation
Jump to search
Description
- Description:
/* Description: Function to select a random item from an array, taking into account item weights. The weights should be Numbers between 0 and 1, with a maximum precision of hundreds. Parameter(s): _this select 0: source Array (Array of Any Value) _this select 1: weights (Array of Number) Returns: Any Value selected item TODO: [*] Algorithm is inefficient? */
(Placeholder description extracted from the function header by BIS_fnc_exportFunctionsToWiki)- Execution:
- call
- Groups:
- Uncategorised
Syntax
- Syntax:
- [array1, array2] call BIS_fnc_selectRandomWeighted;
- Parameters:
- array1: Array - selectable values
- array2: Array of Numbers - values weight: first weight is for array1 first element, etc.
- Return Value:
- Return value needed
Examples
- Example 1:
_choices = ["cat", "dog"]; _weights = [0.5, 1.0]; [_choices, _weights] call BIS_fnc_selectRandomWeighted]; // will result in 2/3 of dogs, 1/3 of cats
Additional Information
- See also:
- selectRandomWeighted
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note