public bool ChiSquaredCriteria(double[] sequence, IDistributionFunction func, double eps) { n = sequence.Length; int[] v = new int[K]; double[] p = new double[K]; double a; double b; double X2 = 0; foreach (var element in sequence) { v[(int)((element + func.Left()) / func.Right() * K)]++; } for (int i = 0; i < K; i++) { a = (1.0 * (i) / K) * (func.Right() - func.Left()) + func.Left(); b = (1.0 * (i + 1) / K) * (func.Right() - func.Left()) + func.Left(); p[i] = func.F(b) - func.F(a); } for (int i = 0; i < K; i++) { X2 += Math.Pow(v[i] - p[i] * n, 2) / (n * p[i]); } ChiSquaredCriteriaP = GetChi(X2); return(ChiSquaredCriteriaP >= eps); }
public bool MomentsCoincidenceTest(double[] sequence, IDistributionFunction func, double eps) { n = sequence.Length; double c1 = Math.Sqrt(12 * n); double c2 = (n - 1.0) / n * Math.Pow(0.0056 * Math.Pow(1.0 / n, 1) + 0.0028 * Math.Pow(1.0 / n, 2) - 0.0083 * Math.Pow(1.0 / n, 3), -1.0 / 2); double m = sequence.Sum() / n; double s = sequence.Sum(x => Math.Pow(x - m, 2)) / n; double ksi1 = Math.Abs(m - 1.0 / 2.0); double ksi2 = Math.Abs(s - 1.0 / 12.0); MomentsCoincidenceP1 = 2 * (1 - GetFi(c1 * ksi1)); MomentsCoincidenceP2 = 2 * (1 - GetFi(c2 * ksi2)); return(MomentsCoincidenceP1 > eps && MomentsCoincidenceP2 > eps); }
public bool KolmogorovCriteria(double[] sequence, IDistributionFunction func, double eps) { int n = sequence.Length; IDistributionFunction empiricalDistributionFunction = new EmpiricalDistributionFunction(sequence); int numberOfPartitions = n * n; double x; Dn = 0; for (int i = 0; i < numberOfPartitions; i++) { x = (1.0 * i / numberOfPartitions) * (func.Right() - func.Left()) + func.Left(); Dn = Math.Max(Dn, Math.Abs(empiricalDistributionFunction.F(x) - func.F(x))); } KolmogorovCriteriaP = GetKolmogorovDistributionFunction(Math.Sqrt(n) * Dn); return(KolmogorovCriteriaP > eps); }