Skip to content

Commit 6134fe5

Browse files
committed
Chapter 03 section 06 updated.
1 parent 8f8e863 commit 6134fe5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

03-Probability-Simulation/06-Three-Gates-Problem/src/ThreeGatesExperiment.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@ public void run(boolean changeDoor){
1717
for(int i = 0 ; i < N ; i ++)
1818
if(play(changeDoor))
1919
wins ++;
20+
2021
System.out.println(changeDoor ? "Change" : "Not Change");
21-
System.out.println("winning rate:" + (double)wins/N);
22+
System.out.println("winning rate: " + (double)wins/N);
2223
}
2324

2425
private boolean play(boolean changeDoor){
2526

27+
// Door 0, 1, 2
2628
int prizeDoor = (int)(Math.random() * 3);
2729
int playerChoice = (int)(Math.random() * 3);
2830

29-
if(playerChoice == prizeDoor)
31+
if( playerChoice == prizeDoor)
3032
return changeDoor ? false : true;
3133
else
3234
return changeDoor ? true : false;
3335
}
3436

3537
public static void main(String[] args) {
3638

37-
int N = 1000000;
39+
int N = 10000000;
3840
ThreeGatesExperiment exp = new ThreeGatesExperiment(N);
3941

4042
exp.run(true);
41 KB
Binary file not shown.

0 commit comments

Comments
 (0)