Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 10016

Ignore:
Timestamp:
10/01/13 21:42:07 (10 years ago)
Message:

#2031 added recommended sample size to sample size influence view

Location:
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3
Files:
3 edited

Unmodified
Removed
• ## branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeDetermination.cs

 r9706 public class SampleSizeDetermination { /// /// Determines for a given sample the sample size by estimating the means. /// Determines for a given sample the required sample size as described in /// Göran Kauermann, Helmut Küchenhoff: Stichproben: Methoden und praktische Umsetzung mit R, chapter 2.27. /// /// The pilot sample. /// Precision. /// Confidence Interval. /// Number of required samples for the given confidence interval and precision. public static int DetermineSampleSizeByEstimatingMean(double[] samples, double e, double conf = 0.95) { if (e < 0) throw new ArgumentException("e needs to be a positive number."); public static int DetermineSampleSizeByEstimatingMean(double[] samples, double conf = 0.95) { if (conf < 0 || conf > 1) throw new ArgumentException("The confidence Interval must be between zero and one."); double result = 0; double var = samples.StandardDeviation(); double n = alglib.invnormaldistribution((conf + 1) / 2); result = Math.Pow(n, 2) * Math.Pow(var, 2) / Math.Pow(e, 2); var confInterval = samples.ConfidenceIntervals(0.95); double e = (confInterval.Item2 - confInterval.Item1) / 2; double s = samples.StandardDeviation(); double z = alglib.invnormaldistribution((conf + 1) / 2); double n = samples.Count(); double result = Math.Pow(s, 2) / ((Math.Pow(e, 2) / Math.Pow(z, 2)) + (Math.Pow(s, 2) / n)); result = Math.Ceiling(result); if (result > int.MaxValue)
• ## branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.Designer.cs

 r9913 this.noRunsLabel = new System.Windows.Forms.Label(); this.splitContainer = new System.Windows.Forms.SplitContainer(); this.sampleSizeTextBox = new System.Windows.Forms.TextBox(); this.xAxisComboBox = new System.Windows.Forms.TextBox(); this.defineSampleSizeButton = new System.Windows.Forms.Button(); this.statisticsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView(); this.tooltip = new System.Windows.Forms.ToolTip(this.components); this.label1 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); // splitContainer.Panel1 // this.splitContainer.Panel1.Controls.Add(this.sampleSizeTextBox); this.splitContainer.Panel1.Controls.Add(this.xAxisComboBox); this.splitContainer.Panel1.Controls.Add(this.defineSampleSizeButton); this.splitContainer.SplitterDistance = 277; this.splitContainer.TabIndex = 23; // // sampleSizeTextBox // this.sampleSizeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.sampleSizeTextBox.Location = new System.Drawing.Point(401, 3); this.sampleSizeTextBox.Name = "sampleSizeTextBox"; this.sampleSizeTextBox.ReadOnly = true; this.sampleSizeTextBox.Size = new System.Drawing.Size(139, 20); this.sampleSizeTextBox.TabIndex = 26; // // xAxisComboBox this.statisticsMatrixView.TabIndex = 0; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(251, 6); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(143, 13); this.label1.TabIndex = 26; this.label1.Text = "Recommended Sample Size:"; // // SampleSizeInfluenceView // this.BackColor = System.Drawing.SystemColors.Window; this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.Controls.Add(this.label1); this.Controls.Add(this.splitContainer); this.Name = "SampleSizeInfluenceView"; this.statisticsGroupBox.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } private System.Windows.Forms.Button defineSampleSizeButton; private System.Windows.Forms.TextBox xAxisComboBox; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox sampleSizeTextBox; } }
• ## branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.cs

 r9998 UpdateAxisLabels(); if (groupSizes.Any()) AddSampleSizeText(); } else { sampleSizeTextBox.Text = string.Empty; } UpdateNoRunsVisibleLabel(); } private void AddSampleSizeText() { sampleSizeTextBox.Text = string.Empty; var usableRuns = Content.Where(r => r.Visible).ToList(); if (!yAxisComboBox.DroppedDown) this.yAxisValue = (string)yAxisComboBox.SelectedItem; List yValue = usableRuns.Select(x => GetValue(x, this.yAxisValue)).ToList(); if (yValue.Any(x => !x.HasValue)) return; double y = SampleSizeDetermination.DetermineSampleSizeByEstimatingMean(yValue.Select(x => x.Value).ToArray()); sampleSizeTextBox.Text = y.ToString(); } Series series = seriesCache.ElementAt(i).Value; double[] seriesValues = series.Points.Select(p => p.YValues[0]).OrderBy(d => d).ToArray(); Tuple confIntervals = new Tuple(double.NaN, double.NaN); if (seriesValues.Count() > 1) confIntervals = seriesValues.ConfidenceIntervals(0.95); matrix[0, i] = seriesValues.Length; matrix[1, i] = seriesValues.Min(); matrix[7, i] = seriesValues.Percentile(0.25); matrix[8, i] = seriesValues.Percentile(0.75); matrix[9, i] = seriesValues.ConfidenceIntervals(0.95).Item1; matrix[10, i] = seriesValues.ConfidenceIntervals(0.95).Item2; matrix[9, i] = confIntervals.Item1; matrix[10, i] = confIntervals.Item2; } statisticsMatrixView.Content = matrix;
Note: See TracChangeset for help on using the changeset viewer.