Accord.Statistics.Testing.TwoSampleWilcoxonSignedRankTest.TwoSampleWilcoxonSignedRankTest C# (CSharp) Method

TwoSampleWilcoxonSignedRankTest() public method

Tests whether the medians of two paired samples are different.
public TwoSampleWilcoxonSignedRankTest ( double sample1, double sample2, TwoSampleHypothesis alternate = TwoSampleHypothesis.ValuesAreDifferent ) : System
sample1 double The first sample.
sample2 double The second sample.
alternate TwoSampleHypothesis The alternative hypothesis (research hypothesis) to test.
return System
        public TwoSampleWilcoxonSignedRankTest(double[] sample1, double[] sample2,
            TwoSampleHypothesis alternate = TwoSampleHypothesis.ValuesAreDifferent)
        {
            if (sample1.Length != sample2.Length)
                throw new DimensionMismatchException("sample2", "Both samples should be of the same size.");

            int[] signs = new int[sample1.Length];
            double[] diffs = new double[sample1.Length];

            // 1. Compute absolute difference and sign function
            for (int i = 0; i < sample1.Length; i++)
            {
                double d = sample1[i] - sample2[i];
                signs[i] = Math.Sign(d);
                diffs[i] = Math.Abs(d);
            }

            this.Hypothesis = alternate;
            Compute(signs, diffs, (DistributionTail)alternate);
        }
TwoSampleWilcoxonSignedRankTest