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

Compute() protected method

Computes the one sample sign test.
protected Compute ( int positive, int total, OneSampleHypothesis alternate ) : void
positive int
total int
alternate OneSampleHypothesis
return void
        protected void Compute(int positive, int total, OneSampleHypothesis 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 OneSampleHypothesis.ValueIsDifferentFromHypothesis:
                    binomialHypothesis = OneSampleHypothesis.ValueIsDifferentFromHypothesis; break;
                case OneSampleHypothesis.ValueIsGreaterThanHypothesis:
                    binomialHypothesis = OneSampleHypothesis.ValueIsSmallerThanHypothesis; break;
                case OneSampleHypothesis.ValueIsSmallerThanHypothesis:
                    binomialHypothesis = OneSampleHypothesis.ValueIsGreaterThanHypothesis; break;
                default: throw new InvalidOperationException();
            }

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