Alright I tested the way below.
Generated x times random numbers between 0~x and then checked the ones that were not generated.
I would assume that it would be very close to 100%. What I mean is all numbers between 0~x are generated.
But results are shocking. About 36% of the numbers are missing.
Is my random function not really random?
Here below my random class:
private static Random seedGenerator = new Random(); private static ThreadLocal<Random> random = new ThreadLocal<Random>(SeededRandomFactory); private static Random SeededRandomFactory() { lock (seedGenerator) return new Random(seedGenerator.Next()); } public static int GenerateRandomValueMin(int irRandValRange, int irMinValue) { return random.Value.Next(irMinValue, irMinValue + irRandValRange); } Here the below results:
Between 0-10, missing numbers count: 4, percent: 40% Between 0-100, missing numbers count: 36, percent: 36% Between 0-1000, missing numbers count: 369, percent: 36,9% Between 0-10000, missing numbers count: 3674, percent: 36,74% Between 0-100000, missing numbers count: 36583, percent: 36,58% Between 0-1000000, missing numbers count: 367900, percent: 36,79% Between 0-10000000, missing numbers count: 3678122, percent: 36,78% Between 0-100000000, missing numbers count: 36797477, percent: 36,8%
Here the code how I check:
File.WriteAllText("results.txt", ""); int irFirst = 10; for (int i = 0; i < 8; i++) { HashSet<int> hsGenerated = new HashSet<int>(); for (int k = 0; k < irFirst; k++) { hsGenerated.Add(GenerateRandomValue.GenerateRandomValueMin(irFirst, 0)); } int irNotFound = 0; for (int k = 0; k < irFirst; k++) { if (hsGenerated.Contains(k) == false) irNotFound++; } string srSonuc = string.Format( "Between 0-{0}, missing numbers count: {1}, percent: {2}%", irFirst, irNotFound, Math.Round((Convert.ToDouble(irNotFound)/Convert.ToDouble(irFirst))*100.0, 2).ToString() ); using (StreamWriter w = File.AppendText("sonuclar.txt")) { w.WriteLine(srSonuc); } irFirst = irFirst * 10; } 

Generate? If you're only generating ten numbers for the 0-10 block, then getting 1 of each number is not expected. An even distribution is only expected on average, i.e. for a very large sample size.