Thursday, March 7, 2013


Is there a way to guess better than random chance? I was thinking about this alot. And wrote a program that simulated this and the results were crazy which sent me on a crazy knowledge spree till I figured out that I rediscovered the Binomial Distribution. HAH.

Here is the dilemma. Say you are playing a game that you guess a number between 1 and 10 and a computer guesses and number between 1 and 10.

These outcomes being either a yes, you win when you both guess the same number, or a no you don't, when you don't.
You are trying to win the most. And you know the probability of these outcomes beforehand. Can I have a better win percentage than guessing 1 every single time (~10%). Our apparent probability for randomly guessing is equal to 1/N . Where N is the number of possible outcomes.

How can I win 10% of the time if I only play a game 9 times. Since winning is an integer. This means my winning percentage for playing 9 Games in a Contest with a 10% win rate is either > 10% or 0.

So the probability that we are above the 10% between 0-9 is much much greater because of the integer rule(I have no idea what this is actually called I just made up a name). The probability increases up to 9 or 19 or 29 &c. Once we hit a number divisible by our probability of success we immediately drop because we can now have an integer higher number of successes.

Let's simulate this.

Trials Probability of > 10% Success
1 0.1
2 0.19
3 0.27
4 0.35
5 0.41
6 0.47
7 0.52
8 0.57
9 0.6
10 0.26

See once we hit 10 our Probability of having greater than 10% success drops because we now need more than 1 success! We can only have an integer number of successes remember! CRAZY!

This is interesting.

Further, we have a binomial distribution.

If we look at a binomial distribution for p=10% and 20 Games/trials which we have from wikipedia!

The x axis is our number of successes and y axis is the probability of x number of successes. Were the blue is 10% chance of success on each attempt, the green is 50% chance and red is 80% chance. Our actual chances of having >= 2 successes in 20 games for a 10% or greater success rate is much greater than 10%! Whoaaaa. Mind blown. Sounds, made-up I know. But let's simulate this and prove it. If we calculate the Binomial Distribution for Chance of success or p = 10%. Here is the Perl code . What what!!! It totally works exactly how the binomial distribution suggests! WHOA!

Here is the calculated Binomial Distribution:

Successes 20 Attempts 30 Attempts
1 0.27017034 0.14130386
2 0.28517981 0.22765622
3 0.19011987 0.23608793
4 0.08977883 0.17706595
5 0.03192136 0.10230477
6 0.00886704 0.04736332
7 0.00197045 0.01804317
8 0.00035578 0.00576379

So the code will calculate how often we break the 10% expected barrier. So for 20 attempts that would be the Sum of 3-8 and for 30 it would be the sum of 4-8. Our simulation results are almost exact! MATH! SCIENCE!

For having greater than 10% success (>2 for 20) the sum for 20 is 32% and with 10000 simulations we have an astounding 32.37%!!! For 30 trials calculated from the Binomial Distribution is 35% and we have 34.93% from the simulation!!

What this says is that we actually have a > 30% chance to beat the odds in a Binomial Trial that one only has a 1/10 chance of success!

My mind is blown. This is true for all replacement Binomials.

So this is what you do. Play the number guessing game with your friend. You both choose a number between 1 and 10 and if you guess the number they guess, you win. Now bet them that you can guess correct greater than 10% of the time. Now play the game 9 times and you have a greater than ~60% chance of winning the bet.


So if you are playing a Binomial game your best chance of success is by playing (1/Probability of Success) -1 games!