Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Working With Numbers Create a random number

Are the odds even? Seems like some dice numbers (2, 4, 5) have better odds than others?

Are the odds even? Seems like some dice numbers (2, 4, 5) have better odds than others?

Daniel Box
Daniel Box
1,939 Points

Hi Hussein, while Math.random() returns only a pseudo-random number, for most cases you can treat the value returned as accurately random. So in the case the odds should be equal and anything seeming otherwise only a short term aberration.

1 Answer

David Kanwisher
David Kanwisher
9,751 Points

http://muller.lbl.gov/teaching/Physics10/old%20physics%2010/chapters%20(old)/4-Randomness.htm

If black has hit 5 times in a row on a roulette table, our perceptions say that "red" is due to hit. But in fact, this isn't true.

Sometimes when we think of generating random numbers between 1 and 6, we think that we will see each number about equally with looking at a small sample size.

For example: (I simply just typed these) 1 3 5 6 2 4 3 2 6

But in reality it can be much different: (I randomly generated these)

6 1 5 3 3 3 3 2 2