Created
April 30, 2013 14:37
-
-
Save JonathanLalou/5489151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testLLN() { | |
final Random random = new Random(); | |
for (int j = 4; j >= 2; j--) { | |
int tries = Integer.MAX_VALUE / (int) (Math.pow(10.0, j)); | |
int equalsEight = 0; | |
Integer x; | |
for (int i = 0; i < tries; i++) { | |
x = random.nextInt(6); | |
if (x == 5) { | |
equalsEight++; | |
} | |
} | |
double actualMean = (double) equalsEight / tries; | |
double theoricalMean = 1.0 / 6.0; | |
double deviation = 100 * (1 - actualMean / theoricalMean); | |
System.out.println("**** Test with Integer.MAX_VALUE / 10^" + j); | |
System.out.println(" Actual Mean: " + actualMean); | |
System.out.println("Theorical Mean: " + theoricalMean); | |
System.out.println("Deviation: " + Double.toString(deviation).substring(0, 8) + "%"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment