Jump to content
Sign in to follow this  
CarlGustaffa

Control random towards a tendency, how?

Recommended Posts

In the past I have done a series of case selects in order to control the output of random. Say i.e. I want the mean to be 0.35, with fair chance of getting 0.0 and 0.7 without totally excluding chance of 1.0.

Given this task, how would you approach it?

Share this post


Link to post
Share on other sites

Simplest solution that comes into mind:

private ["_random"];
if(random 2 > 1) then {
_random = random 1; // 0 - 1
} else {
_random = random 0.7; // 0 - 0.7
};

or a shorter variant

_random = random (if(random 2 > 1) then {1} else {0.7});

I'm not into math this much but in this case tendency will be linear, will look something like this

308143_chances.png

Edited by SaMatra

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×