我正在尝试查看是否可以基于安全随机散列获得正确的分布。我的第一个索引似乎总是加倍。我做错了什么吗
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);
看看输出的第一行
Here is the output
16548
8362
8314
8175
8272
8210