private static void TestRandom(string display, List <double> dist, int iterations) { // Random test double[] collectorINT = new double[dist.Count]; Console.WriteLine("\n- - -"); Console.WriteLine($">> {display} {String.Join(", ", dist)}"); for (int i = 0; i < iterations; i++) { double result = Weighted.Random(dist); collectorINT[(int)result]++; } Console.WriteLine(String.Join(", ", collectorINT)); }
public static void TestRandom() { int counter = 10; List <int> weights = new List <int>(); for (int count = 0; count < counter; count++) { weights.Add(count % 3); } Console.WriteLine(String.Join(", ", weights)); int[] result = new int[counter]; for (int count = 0; count < counter; count++) { result[count] = 0; } for (int count = 0; count < counter * 100; count++) { result[Weighted.Random(weights)]++; } Console.WriteLine(String.Join(", ", result)); }