- Timestamp:
- 10/02/13 13:48:55 (11 years ago)
- Location:
- branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/BonferroniHolm.cs
r9950 r10017 26 26 namespace HeuristicLab.Analysis.Statistics { 27 27 public static class BonferroniHolm { 28 /// <summary> 29 /// Based on David Groppe's MATLAB implementation 30 /// (BSD Licensed, see 31 /// http://www.mathworks.com/matlabcentral/fileexchange/28303-bonferroni-holm-correction-for-multiple-comparisons) 32 /// </summary> 28 33 public static double[] Calculate(double globalAlpha, double[] pValues, out bool[] h) { 29 34 int k = pValues.Length; -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/EnumerableStatisticsExtension.cs
r9998 r10017 29 29 public static class EnumerableStatisticExtensions { 30 30 public static Tuple<double, double> ConfidenceIntervals(this IEnumerable<double> values, double alpha) { 31 if (values.Count() <= 1) return new Tuple<double, double>(double.NaN, double.NaN); 32 31 33 double lower, upper; 32 34 double s = values.StandardDeviation(); … … 40 42 return new Tuple<double, double>(lower, upper); 41 43 } 44 45 // Bessel corrected variance 46 public static double EstimatedVariance(this IEnumerable<double> values) { 47 double n = values.Count(); 48 return values.Variance() * n / (n - 1); 49 } 50 51 // Bessel corrected standard deviation 52 public static double EstimatedStandardDeviation(this IEnumerable<double> values) { 53 double n = values.Count(); 54 return values.StandardDeviation() * n / (n - 1); 55 } 42 56 } 43 57 } -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/KruskalWallis.cs
r9706 r10017 27 27 /// <summary> 28 28 /// Performs the Kruskal-Wallis test and returns the p-Value. 29 /// (source based on R's kruskal.test() )29 /// (source based on R's kruskal.test(), GNU GPL) 30 30 /// </summary> 31 31 public static double Test(double[][] data) { -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/LinearLeastSquaresFitting.cs
r9713 r10017 39 39 int n = y.Count(); 40 40 double sy = y.Sum(); 41 double sx = ((n - 1) * n) / 2 ;41 double sx = ((n - 1) * n) / 2.0; 42 42 double avgy = sy / n; 43 43 double avgx = sx / n; -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeDetermination.cs
r10016 r10017 32 32 /// <param name="samples">The pilot sample.</param> 33 33 /// <param name="conf">Confidence Interval.</param> 34 /// <returns>Number of required samples for the given confidence interval and precision. </returns>34 /// <returns>Number of required samples for the given confidence interval. </returns> 35 35 public static int DetermineSampleSizeByEstimatingMean(double[] samples, double conf = 0.95) { 36 if (conf < 0 || conf > 1) throw new ArgumentException("The confidence Interval must be between zero and one.");36 if (conf < 0.0 || conf > 1.0) throw new ArgumentException("The confidence interval must be between zero and one."); 37 37 38 38 var confInterval = samples.ConfidenceIntervals(0.95); 39 39 double e = (confInterval.Item2 - confInterval.Item1) / 2; 40 double s = samples. StandardDeviation();40 double s = samples.EstimatedStandardDeviation(); 41 41 double z = alglib.invnormaldistribution((conf + 1) / 2); 42 42 double n = samples.Count(); 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 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.EstimatedStandardDeviation(); 59 double z = alglib.invnormaldistribution((conf + 1) / 2); 60 double n = samples.Count(); 61 62 double result = Math.Pow(z, 2) * (Math.Pow(s, 2) / Math.Pow(e, 2)); 45 63 46 64 result = Math.Ceiling(result); -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.Designer.cs
r10016 r10017 163 163 this.sampleSizeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 164 164 | System.Windows.Forms.AnchorStyles.Right))); 165 this.sampleSizeTextBox.Location = new System.Drawing.Point(40 1, 3);165 this.sampleSizeTextBox.Location = new System.Drawing.Point(400, 3); 166 166 this.sampleSizeTextBox.Name = "sampleSizeTextBox"; 167 167 this.sampleSizeTextBox.ReadOnly = true; 168 this.sampleSizeTextBox.Size = new System.Drawing.Size(1 39, 20);168 this.sampleSizeTextBox.Size = new System.Drawing.Size(140, 20); 169 169 this.sampleSizeTextBox.TabIndex = 26; 170 170 // -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.cs
r10016 r10017 256 256 if (yValue.Any(x => !x.HasValue)) return; 257 257 258 double y = SampleSizeDetermination.DetermineSampleSizeByEstimatingMean (yValue.Select(x => x.Value).ToArray());258 double y = SampleSizeDetermination.DetermineSampleSizeByEstimatingMeanForLargeSampleSizes(yValue.Select(x => x.Value).ToArray()); 259 259 sampleSizeTextBox.Text = y.ToString(); 260 260 } … … 315 315 } 316 316 matrix.ColumnNames = columnNames; 317 matrix.RowNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Lower Confidence ", "Upper Confidence" };317 matrix.RowNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Lower Confidence Int.", "Upper Confidence Int." }; 318 318 319 319 for (int i = 0; i < seriesCache.Count; i++) { 320 320 Series series = seriesCache.ElementAt(i).Value; 321 321 double[] seriesValues = series.Points.Select(p => p.YValues[0]).OrderBy(d => d).ToArray(); 322 Tuple<double, double> confIntervals = new Tuple<double, double>(double.NaN, double.NaN); 323 if (seriesValues.Count() > 1) 324 confIntervals = seriesValues.ConfidenceIntervals(0.95); 322 Tuple<double, double> confIntervals = seriesValues.ConfidenceIntervals(0.95); 325 323 matrix[0, i] = seriesValues.Length; 326 324 matrix[1, i] = seriesValues.Min();
Note: See TracChangeset
for help on using the changeset viewer.