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

WilcoxonSignedRankTest() public method

Tests the null hypothesis that the sample median is equal to a hypothesized value.
public WilcoxonSignedRankTest ( double sample, double hypothesizedMedian, OneSampleHypothesis alternate = OneSampleHypothesis.ValueIsDifferentFromHypothesis ) : System
sample double The data samples from which the test will be performed.
hypothesizedMedian double The constant to be compared with the samples.
alternate OneSampleHypothesis The alternative hypothesis (research hypothesis) to test.
return System
        public WilcoxonSignedRankTest(double[] sample, double hypothesizedMedian = 0,
            OneSampleHypothesis alternate = OneSampleHypothesis.ValueIsDifferentFromHypothesis)
        {
            int[] signs = new int[sample.Length];
            double[] diffs = new double[sample.Length];

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

            this.Hypothesis = alternate;

            Compute(signs, diffs, (DistributionTail)alternate);
        }
WilcoxonSignedRankTest