Which set is more “random”?
Math.random() for Java or random for Mathematica? Java is in blue, Mathematica in red.
numbers are from 0 to 50 (51?) 
EDIT:
It’s a histogram generated in Mathematica.
Java Source (ugly)
public static void main(String[] args) {
// TODO Auto-generated method stub
int i = 0;
int sum = 0;
int counter = 0;
String randomNumberList = " ";
int c = 0;
while (c != 50){
while (i != 7) {
i = (int) (51 * Math.random());
sum += i;
++counter;
randomNumberList += " " + i;
}
i = 0;
System.out.print("\n" + randomNumberList);
++c;
}
}
Mathematica source (output.txt is the dump from Java)
dataset = ReadList["~/Desktop/output.txt", Number]
dataset2 = RandomReal [{0, 50}, 50000]
Histogram[{dataset, dataset2}]
[EDIT]: I was just learning loops when I did the code. Sorry for the confusion. Now I made a cleaner version and they are about equally distributed. I guess that arbitrary loop ending made a big difference.

new code:
public class RandomNums {
public static void main(String[] args) {
int count = 0;
for (int i = 0; i <= 50000; i++){
int j = (int) (50 * Math.random());
System.out.print(j + " ");
count++;
if (count == 50){
System.out.println("\n");
count = 0;
}
}
}
}
If this plot suggests anything to me, it is that the quality of Mathematica’s uniform random distribution is much better than the implementation in
Javayou are showing (I don’t claim that for any Java implementation. Also, as a disclaimer, and not to start a flame war, I’ve been both J2EE and Mathematica developer for some time, although admittedly have more experience in the latter).Here is the argument. You have 50000 points and 50 bins (histogram bars) shown, which suggests that you roughly have 1000 points per bin. More precisely, we can use ergodicity to cast the problem of 50000 uniformly distributed points into that of 50000 independent trials, and ask what is the mean number of points to end up in each bin, and the variance. The probability that any particular bin ends up with exactly
kpoints out ofNpointsis given then by a binomial distribution:For which, the mean is
Npoints/Nbins(which is what we expect intuitively, of course), and the variance isNpoints * (1-1/Nbins)* 1/Nbins ~ Npoints/Nbins = 1000, in our case (Npoints = 50000, Nbins = 50). Taking a square root, we get the standard deviation assqrt(1000) ~ 32, which is about 3% of the mean (which is1000). The conclusion is that, for an ideal uniform distribution, and for a given number of points and bins, we should expect deviations from the mean of the order of 3%, for each bin. And this is very similar to what Mathematica distribution gives us, judging by the picture. The deviations for individual bins for Java distribution (again, the particular implementation presented here), are much larger, and suggest correlations between bins and that overall this uniform distribution is of much poorer quality.Now, this is a “high-level” argument, and I am not going into details to discover the reason. This seems logical however, given that the traditional target audience for Mathematica (sciences, academia) is (or at least used to be) much more demanding in this respect, than that for Java. That said, I have no doubts that there exist many excellent Java implementations of random number generators for many statistical distributions – they are just not something built into the language, unlike in Mathematica.