public static void TestEvenly() { double[] data = new double[100]; for (int i = 0; i < data.Length; i++) { data[i] = Generator.EvenlyGenerate(0, 10); } double[] probability = new double[K]; foreach (double z in data) { probability[(int)(z / (1.0d / K))]++; } Histogramma.Build1(probability); double expectation = GetExpectation(data); Console.WriteLine($"Равномерное n = 100, M = {expectation}"); Console.WriteLine($"D = {GetDispersion(data, expectation)}"); Console.WriteLine($"Вероятность по {K} карманам"); foreach (double p in probability) { Console.Write($"{p / data.Length} "); } Console.WriteLine(); data = new double[10000]; for (int i = 0; i < data.Length; i++) { data[i] = Generator.EvenlyGenerate(0, 10); } probability = new double[K]; foreach (double z in data) { probability[(int)(z / (1.0d / K))]++; } expectation = GetExpectation(data); Console.WriteLine($"Равномерное n = 10000, M = {expectation}"); Console.WriteLine($"D = {GetDispersion(data, expectation)}"); Console.WriteLine($"Вероятность по {K} карманам"); foreach (double p in probability) { Console.Write($"{p / data.Length} "); } Console.WriteLine(); }
static void Main(string[] args) { List <double> arr = new List <double>(); for (int i = 0; i < 10000; i++) { arr.Add(Generator.EvenlyGenerate(0, 20)); } //Histogramma.Build(arr); double[] arr1 = new double[] { 0.1, 0.2, 0.3, 0.5 }; Histogramma.Build1(arr1); }