Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/05/15 16:09:10 (9 years ago)
Author:
ascheibe
Message:

#2031 implemented review comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis/3.3/Statistics/SampleSizeDetermination.cs

    r11703 r11914  
    3636      if (conf < 0.0 || conf > 1.0) throw new ArgumentException("The confidence interval must be between zero and one.");
    3737
    38       var confInterval = samples.ConfidenceIntervals(0.95);
     38      var confInterval = samples.ConfidenceIntervals(conf);
    3939      double e = (confInterval.Item2 - confInterval.Item1) / 2;
    4040      double s = samples.StandardDeviation();
     
    4343
    4444      double result = Math.Pow(s, 2) / ((Math.Pow(e, 2) / Math.Pow(z, 2)) + (Math.Pow(s, 2) / n));
    45 
    46       result = Math.Ceiling(result);
    47       if (result > int.MaxValue)
    48         return int.MaxValue;
    49       else
    50         return (int)result;
    51     }
    52 
    53     public static int DetermineSampleSizeByEstimatingMeanForLargeSampleSizes(double[] samples, double conf = 0.95) {
    54       if (conf < 0.0 || conf > 1.0) throw new ArgumentException("The confidence interval must be between zero and one.");
    55 
    56       var confInterval = samples.ConfidenceIntervals(0.95);
    57       double e = (confInterval.Item2 - confInterval.Item1) / 2;
    58       double s = samples.StandardDeviation();
    59       double z = alglib.invnormaldistribution((conf + 1) / 2);
    60 
    61       double result = Math.Pow(z, 2) * (Math.Pow(s, 2) / Math.Pow(e, 2));
    6245
    6346      result = Math.Ceiling(result);
Note: See TracChangeset for help on using the changeset viewer.