Discuss Scratch

ideapad-320
Scratcher
100+ posts

Pich random block is not very random.

My browser / operating system: Windows NT 10.0, Chrome 66.0.3359.181, Flash 30.0 (release 0)
try running
(pick random (1) to (2))
see? 1 is picked more often

Last edited by ideapad-320 (June 12, 2018 19:32:21)

LionHeart70
Scratcher
1000+ posts

Pich random block is not very random.

Probably not a glitch. When faced with very small intervals like that, you often get it to pick one more than the other.
If it were picking something like 1, 2, 1, 2, then that wouldn't be very random either since that's in a pattern.

lh70 / nora/tobi / she-they pronouns / pansexual-asexual / 13 / sagittarius / furry / artist / stop-motion films / fall out boy / panic! at the disco / a series of unfortunate events
“When you have a bad day, a really bad day, try and treat the world better than it treated you.” -Patrick Stump
CeruleanRose
Scratcher
94 posts

Pich random block is not very random.

It is just a coincidence. Try running it 500 times. You’ll see. Small intervals are easy to mix up. If you ran it 10 times, odds are it’s not exactly 5-5. It won’t be exact or it’ll be a pattern. (Unless it lands on the one in a million)

Save :: #FFFF00 stack
the :: #000000 stack
bees! :: #FFFF00 stack
 Read this if you have time! This little thingie lets me type a whole lot of text into my siggy. I can fit whatever I want into it. Just use the [code] and [/code] tags. By the way, save the bees! You might be thinking, why do I care about little annoying bugs with stingers? Well, bees pollinate plants.
Plants provide food. Just eat meat? Cows and pigs and other animals eat plants. No pollinators? No food! Also, plants produce OXYGEN. That's what you breathe, people. Thank you for listening to my rant about bees. Goodbye! See ya!
ideapad-320
Scratcher
100+ posts

Pich random block is not very random.

I ran it a bunch. it seems to happen only at the beginning
-ShadowOfTheFuture-
Scratcher
1000+ posts

Pich random block is not very random.

I mean, if you run it very few times, one will almost certainly be picked a lot more than the other (if you ran it 2 times only, there's a 1/2 chance that both times will be the same number). But if you run it, say, 5000 times, or 10000 times, overall it'll likely come out to be around even.

But then again, the pick random block only uses “pseudo-randomness”, but I doubt that would have much of an impact on how random it seems.

Before you post in the Suggestions forum, please remember to check out the List of Rejected Suggestions. Thanks!

Flowermanvista
Scratcher
25 posts

Pich random block is not very random.

Just to add to this, the “pick random” block uses a pseudo-random algorithm, which isn't really true randomness, but in most cases, such as Scratch projects, it is close enough to true randomness that it isn't really a problem. I threw together a quick experiment and I tested 10,000,000 iterations of picking randomly from 1 or 2. I zoomed in on a small section of the graph, and it seems to have a slight preference for twos over ones, but the difference is small enough (less than 0.1%) that it would not be a problem for casual uses.



I decided to do a second test, using numbers 1 to 10. As expected, there was some deviation from the expected 1,000,000 for each, but no significant biases. Again, it's very close - close enough that in almost all cases, it would be good enough.



In both cases, if it was zoomed out, it would look like all bars were the same height.

In conclusion, it seems to be, for the most part, a fairly good pseudo-random number generator.

Last edited by Flowermanvista (June 13, 2018 22:11:31)


This user isn't very active here on Scratch anymore. In the meantime I recommend going here or here.

Powered by DjangoBB

Standard | Mobile