public DependedWilcoxonSignedRanksHomogeneition(List <double> firstSequence, List <double> secondSequence) { var z = firstSequence.Zip(secondSequence, (x, y) => x - y).Where(i => i != 0).ToList(); var N = z.Count; z.Sort((x, y) => x.CompareTo(y)); List <Tuple <double, int> > signSeria = z.Select(x => new Tuple <double, int>(Math.Abs(x), x > 0 ? 1 : 0)).ToList(); signSeria.Sort((x, y) => x.Item1.CompareTo(y.Item1)); List <double> zAbs = z.Select(Math.Abs).ToList(); RankSelection zAbsRanged = new RankSelection(); zAbsRanged.AddSelection(zAbs); var T = zAbsRanged.Selection.Zip(signSeria, (r, a) => r.rank * a.Item2).Sum(); var ET = N * (N + 1) / 4; double DT; if (zAbsRanged.Selection.Select(i => i.rank).Distinct().Count() == zAbsRanged.Selection.Count()) { DT = N * (N + 1) * (2 * N + 1) / 24; } else { DT = (N * (N + 1) * (2 * N + 1) - zAbsRanged.Ranks.Sum(r => r.Count * (r.Count - 1) * (r.Count + 1)) / 2) / 24; } Statistic = (T - ET) / Math.Sqrt(DT); Statistic = double.IsNaN(Statistic) ? 0 : Statistic; Quantil = Quantiles.u_Normal(1 - alpha / 2); }
public IndependedWilcoxonSignedRanksHomogeneition(List <double> firstSequence, List <double> secondSequence) { int N1 = firstSequence.Count; int N2 = secondSequence.Count; Quantil = Quantiles.u_Normal(1 - alpha / 2); RankSelection z = new RankSelection(); var fsNumber = z.AddSelection(firstSequence); z.AddSelection(secondSequence); var W = z.Selection.Where(i => i.selection == fsNumber).Select(r => r.rank).Sum(); var E = (N1 * (N1 + N2 + 1)) / 2; var D = N1 * N2 * (N1 + N2 + 1) / 12; Statistic = (W - E) / Math.Sqrt(D); Statistic = double.IsNaN(Statistic) ? 0 : Statistic; }