RandomBetween Not very Random
-
I've set up two separeate variables to generate "RandBetween(1,5)" and "OnClick" to "Redraw". When Redraw occurs, I invariably get the exact same result on BOTH RandBetween variables. I would have expected 2 different random values.
Nino
-
Hi Nino,
I see the same behavior. Seems like a bug in DC's.
As an alternative, you can use something like:
=round(rand() * 4 + 1)
-
Same with RAND()...
If the formula is the same, the result is the same.But, if you add a number between the bracket, the random number will be different for each different number.
= CEILING ( RAND(1) * 5) (same as = ROUND ( RAND(1) * 5 + 1)
generate different result than
= CEILING ( RAND(2) * 5)@jim said:
As an alternative, you can use something like:
=round(rand() * 4 + 1)Be carrefull, this is not the same as RANDBETWEEN(1,5), giving a number in [1, 2, 3, 4,5].
ROUND(RAND() * 4 + 1) give a number in [1, 2, 3, 4].RAND() give a number 0 =< X < 1
RAND() * 4 give a number 0 =< X < 4
RAND() * 4 + 1 give a number 1 =< X < 5 -
Here's what I did. 3 identical formulas, 3 different values between 1 and 5.
-
@daredevil said:
Same with RAND()...
If the formula is the same, the result is the same.@jim said:
Here's what I did. 3 identical formulas, 3 different values between 1 and 5.
I was intresded with your video : all the opposite to my experience !!
So... I tested and tested again, and finally I understand why !!!
If you type in uppercase (RAND() or RANDBETWEEN(1,5)) or use the help to insert function (that write it in uppercase), same formulas produce same result.
But if you write in lowercase (rand() or randbetween(1,5)) each folmula produce a different result, the random is "realy" random !If you use mixed case, Rand() produce same result as other Rand(), but different to RaNd() that produce same as other RaNd()...
I used to type in uppercase in DC, but now, I will always use lowercase, like in Ruby

Thanks Jim for you exemple

-
Hi Didier,
Thank you for investigating further.
I am very surprised that the difference of behavior is based on the case of the letters! Not cool.
-
@daredevil said:
@daredevil said:
Same with RAND()...
If the formula is the same, the result is the same.@jim said:
Here's what I did. 3 identical formulas, 3 different values between 1 and 5.
I was intresded with your video : all the opposite to my experience !!
So... I tested and tested again, and finally I understand why !!!
If you type in uppercase (RAND() or RANDBETWEEN(1,5)) or use the help to insert function (that write it in uppercase), same formulas produce same result.
But if you write in lowercase (rand() or randbetween(1,5)) each folmula produce a different result, the random is "realy" random !If you use mixed case, Rand() produce same result as other Rand(), but different to RaNd() that produce same as other RaNd()...
I used to type in uppercase in DC, but now, I will always use lowercase, like in Ruby

Thanks Jim for you exemple

If anybody was going to provide an answer . . . . it was shure to be SketchUcation. THANKS.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement