Accord.Statistics.Testing.Power.BaseOneSamplePowerAnalysis.ComputeSamples C# (CSharp) Метод

ComputeSamples() публичный Метод

Computes recommended sample size for the test to attain the power indicated in Power considering values of Effect and Size.
public ComputeSamples ( ) : void
Результат void
        public virtual void ComputeSamples()
        {
            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(n =>
            {
                Samples = n;
                ComputePower();

                return requiredPower - Power;
            },

            lowerBound: 2,
            upperBound: 1e+4);


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

            double newPower = Power;
            Power = requiredPower;

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