-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquantumParadoxSimulator.java
More file actions
94 lines (86 loc) · 1.86 KB
/
Copy pathquantumParadoxSimulator.java
File metadata and controls
94 lines (86 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package lab9;
public class quantumParadoxSimulator
{
public static void main (String args[])
{
int previous=0;
int count=0;
int []rollstaken= new int[900000];
//roll a dice
for(int i=0;i<900000;i++)
{
int dice=roll();
//System.out.println(dice);
if(dice==6)
{
rollstaken[count]=i-previous;
previous=i;
count++;
}
}
previous=0;
int count2=0;
int []rollstaken2= new int[900000];
//roll a dice
for(int i=0;i<900000;i++)
{
int dice=rollsnap();
//System.out.println(dice);
if(dice==7)
{
rollstaken2[count2]=i-previous;
previous=i;
count2++;
}
}
previous=0;
int count3=0;
int []rollstaken3= new int[900000];
//roll a dice
for(int i=0;i<900000;i++)
{
int dice=rollsnapsnee();
//System.out.println(dice);
if(dice==8)
{
rollstaken3[count3]=i-previous;
previous=i;
count3++;
}
}
double result1= getmean(rollstaken,count);
double result2= getmean(rollstaken2,count2);
double result3= getmean(rollstaken3,count3);
System.out.println(" "+result1+" vs "+result2+" vs "+result3+" a difference of: ");
}
public static double getmean(int[]x,int count)
{
int rows=count;
double sum=0;
double mean=0;
for(int r= 1 ; r<count;r++)
{
sum+= x[r];
}
mean=((sum)/(count));
return mean;
}
public static int roll()
{
int res = (int)(Math.random()*6) + 1;
return res;
}
public static int rollsnap()
{
int res = (int)(Math.random()*3) + 1;
int res2 = (int)(Math.random()*4) + 1;
return (res+res2);
}
public static int rollsnapsnee()
{
int res = (int)(Math.random()*3) + 1;
int res2 = (int)(Math.random()*3) + 1;
int res3 = (int)(Math.random()*2) + 1;
return (res+res2+res3);
}
}