Jump to content
Sign in to follow this  
wyattwic

Using random to return values with preference to the outer range

Recommended Posts

Hello everyone!

 

Currently randoms syntax of "random [0,5,10]" produces random numbers between 0 and 10, with preference to the center of that range.

 

Is there any way to have random prefer both outer edges of that range, instead of the center?

 

Thank you,

Share this post


Link to post
Share on other sites

I re-read my post and I was unsure if I was making my goal clear.

 

Currently I have two ranges subtracted against a 2d position, both are randomized using [-100,0,100] producing figure A in the below image.  What would it take to get something similar to figure B?

 

http://i.imgur.com/QVH9BTg.png

Share this post


Link to post
Share on other sites

According to the examples, I understand that a higher mid value than max and min, generates a higher number. So I guess that you can use

floor(random [50,100,50]) * selectRandom [1,-1];

The last is just to generate negative numbers also. There's most likely a better way. Increase min and max to increase the generated number.

Share this post


Link to post
Share on other sites

Hello everyone!

Currently randoms syntax of "random [0,5,10]" produces random numbers between 0 and 10, with preference to the center of that range.

Is there any way to have random prefer both outer edges of that range, instead of the center?

Thank you,

this should do exactly what u want:

if ((random 10) < 5) then
{
 _value = random [0, 100, 0];
}
else
{
 _value = random [0, -100, 0];
};
Edited by sarogahtyp

Share this post


Link to post
Share on other sites

hmm... idk what is faster but while thinking about both solution I figured out that fiddi did the same with another way :)

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  

×