public static double GetLambda(double[] sample) { List <double> arr = new List <double>(sample); var normal2 = new MathNet.Numerics.Distributions.Normal(); arr.Sort(); double dMax = 0.0; double dp, dm; double MX = StatisticData.CalculateMathExpectation(sample); double D = StatisticData.CalculateDispersoin(sample, MX); for (int i = 0; i < arr.Count; i++) { double v = (arr[i] - MX) / Math.Sqrt(D); dp = Math.Abs((double)(i + 1) / arr.Count - normal2.CumulativeDistribution(v)); dm = Math.Abs(normal2.CumulativeDistribution(v) - (double)i / arr.Count); if (dp > dMax) { dMax = dp; } if (dm > dMax) { dMax = dm; } } return(dMax * Math.Sqrt(arr.Count)); }
private void Form1_Load(object sender, EventArgs e) { double[] randomValues = WalkModeling.Calculate(); leftXBorder = randomValues.Min(); rightXBorder = randomValues.Max(); double averageDistance = randomValues.Sum() / randomValues.Length; double mx = StatisticData.CalculateMathExpectation(randomValues); double dx = StatisticData.CalculateDispersoin(randomValues, mx); double N = tb * tb * dx / (d * d); label5.Text = $"Оптимальный объем выборки = {N}"; // GetAverageDistances(); ConstructFrequencyHistogram(randomValues); ConstructStatisticalDistributionFunction(randomValues); //вычисление критерия Колмагорова double kolmogorovCriterionLambdaValue = KolmogorovCriterion.GetLambda(randomValues); double kolmogorovCriterionValue = KolmogorovCriterion.Calculate(randomValues, randomValues.Length); label1.Text = "средняя дистанция = " + averageDistance; //label2.Text = $"Лямбда по критерию Колмогорова равна {Math.Round(kolmogorovCriterionLambdaValue, 3)}; \nОценка генератора " + // $"случайных чисел равна {kolmogorovCriterionValue}"; }