Accord.Statistics.Testing.TwoSampleSignTest.Compute C# (CSharp) Method

Compute() protected method

Computes the two sample sign test.
protected Compute ( int positive, int total, TwoSampleHypothesis alternate ) : void
positive int
total int
alternate TwoSampleHypothesis
return void
        protected void Compute(int positive, int total, TwoSampleHypothesis alternate)
        {
            this.Hypothesis = alternate;

            // The underlying test is to check whether the probability
            // value from the samples are higher than or lesser than 0.5,
            // thus the actual Binomial test hypothesis is inverted:

            OneSampleHypothesis binomialHypothesis;

            switch (alternate)
            {
                case TwoSampleHypothesis.ValuesAreDifferent:
                    binomialHypothesis = OneSampleHypothesis.ValueIsDifferentFromHypothesis; break;
                case TwoSampleHypothesis.FirstValueIsGreaterThanSecond:
                    binomialHypothesis = OneSampleHypothesis.ValueIsSmallerThanHypothesis; break;
                case TwoSampleHypothesis.FirstValueIsSmallerThanSecond:
                    binomialHypothesis = OneSampleHypothesis.ValueIsGreaterThanHypothesis; break;
                default: throw new InvalidOperationException();
            }


            base.Compute(positive, total, 0.5, binomialHypothesis);
        }