Accord.Statistics.Testing.Power.BaseTwoSamplePowerAnalysis.ComputeSize C# (CSharp) Method

ComputeSize() public method

Computes the minimum significance level for the test considering the power given in Power, the number of samples in TotalSamples and the effect size Effect.
public ComputeSize ( ) : void
return void
        public virtual void ComputeSize()
        {
            double requiredPower = Power;

            // Attempt to locate the optimal sample size
            // to attain the required power by locating
            // a zero in the difference function:

            double sol = BrentSearch.FindRoot(alpha =>
            {
                Size = alpha;
                ComputePower();

                return requiredPower - Power;
            },

            lowerBound: 0,
            upperBound: 1);


            // Check it
            Size = sol;
            ComputePower();

            double newPower = Power;
            Power = requiredPower;

            if (Math.Abs(requiredPower - newPower) > 1e-5)
                Effect = Double.NaN;
        }