Example #1
0
        /// <summary>
        ///   Estimates the number of samples necessary to attain the
        ///   required power level for the given effect size.
        /// </summary>
        ///
        /// <param name="sampleSize">The number of observations in the sample.</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 TTestPowerAnalysis GetEffectSize(int sampleSize, double power   = 0.8, double alpha = 0.05,
                                                       OneSampleHypothesis hypothesis = OneSampleHypothesis.ValueIsDifferentFromHypothesis)
        {
            TTestPowerAnalysis analysis = new TTestPowerAnalysis(hypothesis)
            {
                Samples = sampleSize,
                Size    = alpha,
                Power   = power,
            };

            analysis.ComputeEffect();

            return(analysis);
        }
Example #2
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 TTestPowerAnalysis GetSampleSize(double delta,
                                                       double standardDeviation       = 1, double power = 0.8, double alpha = 0.05,
                                                       OneSampleHypothesis hypothesis = OneSampleHypothesis.ValueIsDifferentFromHypothesis)
        {
            TTestPowerAnalysis analysis = new TTestPowerAnalysis(hypothesis)
            {
                Effect = delta / standardDeviation,
                Size   = alpha,
                Power  = power,
            };

            analysis.ComputeSamples();

            return(analysis);
        }