Page MenuHomeFeedback Tracker

BIS_fnc_randomPos does not produce points in a uniform distribution
New, WishlistPublic

Description

It appears to be the case that results of BIS_fnc_randomPos conform to a non-uniform distribution, as shown in the attached screenshots.

The behaviour is observed when using BIS_fnc_randomPos, but I believe the problem is in the implementation of BIS_fnc_randomPosTrigger, which BIS_fnc_randomPos uses.

The first screenshot is the result of the behaviour of BIS_fnc_randomPos. The distribution appears to follow a pattern, and, while the points themselves are random, they do not appear to follow a uniform distribution. The associated code is under "Additional Information". Repeating the experiment yields similar results.

The second screenshot is the result of using an implementation found on stackoverflow. It more closely resembles the kind of results that I would expect from BIS_fnc_randomPos. Again, the associated code is under "Additional Information". {F24583} {F24584}

Details

Legacy ID
2350060524
Severity
None
Resolution
Open
Reproducibility
Have Not Tried
Category
Scripting
Additional Information

Using BIS_fnc_randomPos:

    for "_i" from 0 to 2500 do
    {
        private ["_randpoint"];
        _randpoint = [
            [[(getMarkerPos "THINGY_MARKER"), 10000]],
            ["out"]
            ] call BIS_fnc_randomPos;
         _randpoint set [2, 0];
         [_randpoint, "mil_dot", "ColorBLACK", [.5]] call BIS_fnc_markerCreate;
    };

Alternative Implementation (see https://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly):

private ["_randvec","_randpoint","_t","_u","_r"];
for "_i" from 0 to 2000 do
{
    _t = pi * 2 * random 1;
    _u = random 1 + random 1;
    _r = if (_u > 1) then { 2 - _u } else { _u };
    _randvec = [_r * cos (180 * _t), _r * sin (180 * _t)];
    _randvec set [2, 0];
    _randvec = _randvec vectorMultiply 10000;
    _randpoint = (getMarkerPos "THINGY_MARKER") vectorAdd _randvec;
    [_randpoint, "mil_dot", "ColorBLACK", [.5]] call BIS_fnc_markerCreate;
};

Event Timeline

sqwishy edited Steps To Reproduce. (Show Details)Aug 12 2014, 3:16 AM
sqwishy edited Additional Information. (Show Details)
sqwishy set Category to Scripting.
sqwishy set Reproducibility to Have Not Tried.
sqwishy set Severity to None.
sqwishy set Resolution to Open.
sqwishy set Legacy ID to 2350060524.May 7 2016, 7:12 PM
Bohemia added a subscriber: AD2001.Aug 12 2014, 3:16 AM