Once I read about the Monty Hall Problem in high school, I became pretty interested in exploring it. Didn't do much other than try to understand it intuitively and create a simulator to kind of "prove out" the solution.
read more
import java.util.Random;
public class monteHall {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Random generator = new Random();
int placer=0;
int chooser=0;
int i=0;
int f=0;
double wins=0;
double losses=0;
double ratio =0;
String positions[] = new String[3];
placer=generator.nextInt(3);
while(f<100){
placer=generator.nextInt(3);
positions[placer]="goat";
placer=placer+1;
if(placer==3){
placer=0;}
positions[placer]="goat";
placer=placer+1;
if(placer==3){
placer=0;}
positions[placer]="car";
chooser=generator.nextInt(3);
if(positions[chooser]=="goat"){
wins++;
}
if(positions[chooser]=="car"){
losses++;
}
f++;
}
ratio=(wins/(wins+losses))*100;
System.out.println(ratio+"%");
}
}