- Timestamp:
- 02/05/15 16:09:10 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis/3.3/Statistics/SampleSizeDetermination.cs
r11703 r11914 36 36 if (conf < 0.0 || conf > 1.0) throw new ArgumentException("The confidence interval must be between zero and one."); 37 37 38 var confInterval = samples.ConfidenceIntervals( 0.95);38 var confInterval = samples.ConfidenceIntervals(conf); 39 39 double e = (confInterval.Item2 - confInterval.Item1) / 2; 40 40 double s = samples.StandardDeviation(); … … 43 43 44 44 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 else50 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));62 45 63 46 result = Math.Ceiling(result);
Note: See TracChangeset
for help on using the changeset viewer.