File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
03-Probability-Simulation
06-Three-Gates-Problem/src Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -17,24 +17,26 @@ public void run(boolean changeDoor){
17
17
for (int i = 0 ; i < N ; i ++)
18
18
if (play (changeDoor ))
19
19
wins ++;
20
+
20
21
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 );
22
23
}
23
24
24
25
private boolean play (boolean changeDoor ){
25
26
27
+ // Door 0, 1, 2
26
28
int prizeDoor = (int )(Math .random () * 3 );
27
29
int playerChoice = (int )(Math .random () * 3 );
28
30
29
- if (playerChoice == prizeDoor )
31
+ if ( playerChoice == prizeDoor )
30
32
return changeDoor ? false : true ;
31
33
else
32
34
return changeDoor ? true : false ;
33
35
}
34
36
35
37
public static void main (String [] args ) {
36
38
37
- int N = 1000000 ;
39
+ int N = 10000000 ;
38
40
ThreeGatesExperiment exp = new ThreeGatesExperiment (N );
39
41
40
42
exp .run (true );
You can’t perform that action at this time.
0 commit comments