I am trying to see if I can get a proper distribution based on secure random hash. I always seem to get double for my first index. Is there something wrong that I am doing
SecureRandom sr = new SecureRandom();
sr.setSeed(sr.generateSeed(16));
int zero = 0;
int one = 0;
int two = 0;
int three = 0;
int four = 0;
int five = 0;
int six =0;
for (int i = 0 ; i < 100000; i++) {
long index = sr.nextLong()%6;
if(index == 0)
zero++;
else if (index == 1)
one++;
else if(index == 2)
two++;
else if(index == 3)
three++;
else if(index == 4)
four++;
else if(index == 5)
five++;
}
System.out.println(zero);
System.out.println(one);
System.out.println(two);
System.out.println(three);
System.out.println(four);
System.out.println(five);
System.out.println(six);
Take a look at the first line of the output
Here is the output
16548
8362
8314
8175
8272
8210