Accord.Statistics.Testing.Power.ZTestPowerAnalysis.ComputeSamples C# (CSharp) Method

ComputeSamples() public method

Gets the recommended sample size for the test to attain the power indicating in IPowerAnalysis.Power considering values of IPowerAnalysis.Effect and IPowerAnalysis.Size.
public ComputeSamples ( ) : void
return void
        public override void ComputeSamples()
        {
            double Za = ZTest.PValueToStatistic(Size, Tail);
            double Zb = NormalDistribution.Standard
                .InverseDistributionFunction(Power);

            double n = (Za + Zb) / Effect;

            Samples = n * n;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        ///   Estimates the number of samples necessary to attain the
        ///   required power level for the given effect size.
        /// </summary>
        ///
        /// <param name="delta">The minimum detectable difference.</param>
        /// <param name="standardDeviation">The difference standard deviation.</param>
        /// <param name="power">The desired power level. Default is 0.8.</param>
        /// <param name="alpha">The desired significance level. Default is 0.05.</param>
        /// <param name="hypothesis">The alternative hypothesis (research hypothesis) to be tested.</param>
        ///
        /// <returns>The required number of samples.</returns>
        ///
        public static ZTestPowerAnalysis GetSampleSize(double delta,
                                                       double standardDeviation       = 1, double power = 0.8, double alpha = 0.05,
                                                       OneSampleHypothesis hypothesis = OneSampleHypothesis.ValueIsDifferentFromHypothesis)
        {
            ZTestPowerAnalysis analysis = new ZTestPowerAnalysis(hypothesis)
            {
                Effect = (delta) / standardDeviation,
                Size   = alpha,
                Power  = power,
            };

            analysis.ComputeSamples();

            return(analysis);
        }
All Usage Examples Of Accord.Statistics.Testing.Power.ZTestPowerAnalysis::ComputeSamples