Friday, February 11, 2011

PaRaDoX!? -When Reality Becomes Stranger Than Fiction

RadiolabImage via Wikipedia


Paradox can mean many things, such as in my discrete math class, where it defines a particular logical statement to be impossible. A paradox can also describe something that is counter-intuitive (you would think the opposite of the actuality). Today at work I listened to RadioLab (a cool NPR/WNYC podcast I recently found) titled "Numbers." While it wasn't quite as good as "Lost & Found", it is definitely up there...along with basically every other episode (http://www.radiolab.org/2009/nov/30/).
BenfordsLawThey were talking about something called Benford's law. Basically, if you find anything numerical, then the first number is most likely to be 1 (30% chance, aprox.- according to the chart above...calculated by averaging first digit from many sources). It was amazing to see how this serendipitous discovery led to so many applications, going as far as use as evidence in criminal court cases. Investigators can look at someone's bank account balance and if it doesn't follow Benford's law, then they may be committing fraud. It seems so, what's the word...oh, ya..."counter-intuitive"? Nevertheless, it seems to hold true (listen to podcast to learn more).



Monty Hall paradox illustrationImage via Wikipedia
This got me thinking about another paradox I ran into a while back called the Monty Hall Paradox. For just a second, imagine you are on a gameshow and the host shows you 3 different doors. Behind one door is a goat, another has a Porsche an the other contains nothing. The host then asks you to pick a door (in hopes of getting the Porsche, of course), so you randomly pick a door, say #3. The host then tells you that there definitely nothing behind #2 and proves it to you by opening it. Lastly, he asks you if you would like to switch or open the other door. Which should you do? Does it even make a difference? Answer...?

You should always switch because when you originally picked the 1st door you only had a 33% chance of picking the Porsche and now between the two doors that are left, there is a 50% chance. I found this interesting, but didn't quite understand (and you are probably still scratching your head too I suppose? ^_^). This is why I decided to put my Java programming skills to use to write a program to test this out. When writing I realized there were several possibilities (going under assumption that you always switch):
1) I originally picked the ONE door with the Porsche  and when I switch I will get crap.
2) I picked one of the other TWO booby prize doors and when I switch I will get the Porsche.
Ok, point proven...but if you are still unsatisfied you can try it yourself or run my java source code:


import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

/**
 *
 * @author JT Newsome
 * Demonstrates the Monty Hall Paradox and theory of probability.
 *
 */
public class MontyHallTester {
public static int forMonty = 0;
public static int againstMonty = 0;
public static int min = 0;
public static int max = 2;
public static int timesToLoop = 1000000;

public static void main(String[] args) {
for(int i = 0; i < timesToLoop; i++){
montyTest();
}
System.out.println("forMonty: "+forMonty);
System.out.println("againstMonty: "+againstMonty);
System.out.println("Ratio: "+ (forMonty/againstMonty));
}

public static void montyTest(){
ArrayList boxes = new ArrayList();
boxes.add(0);
boxes.add(1);
boxes.add(2);
Collections.shuffle(boxes);
Random rand = new Random();
int randomNum1 = rand.nextInt(max - min + 1) + min;
if (boxes.get(randomNum1) == 2){
againstMonty++;
}
else forMonty++;
}

}


Ok, well that was fun! Happy days until we meet again!
Enhanced by Zemanta

No comments:

Post a Comment