Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/08/14 23:31:39 (10 years ago)
Author:
ascheibe
Message:

#2031 worked on sample size influence view

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

Legend:

Unmodified
Added
Removed
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.Designer.cs

    r11375 r11670  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    49       System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
     48      System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
     49      System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
    5050      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SampleSizeInfluenceView));
    5151      this.xAxisLabel = new System.Windows.Forms.Label();
     
    5555      this.noRunsLabel = new System.Windows.Forms.Label();
    5656      this.splitContainer = new System.Windows.Forms.SplitContainer();
     57      this.hypergeometricCheckBox = new System.Windows.Forms.CheckBox();
     58      this.label1 = new System.Windows.Forms.Label();
     59      this.RecalculateButton = new System.Windows.Forms.Button();
    5760      this.sampleSizeTextBox = new System.Windows.Forms.TextBox();
    58       this.xAxisComboBox = new System.Windows.Forms.TextBox();
     61      this.xAxisTextBox = new System.Windows.Forms.TextBox();
    5962      this.defineSampleSizeButton = new System.Windows.Forms.Button();
    6063      this.showStatisticsCheckBox = new System.Windows.Forms.CheckBox();
     
    6265      this.statisticsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
    6366      this.tooltip = new System.Windows.Forms.ToolTip(this.components);
    64       this.label1 = new System.Windows.Forms.Label();
    6567      ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    6668      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     
    7577      this.xAxisLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    7678      this.xAxisLabel.AutoSize = true;
    77       this.xAxisLabel.Location = new System.Drawing.Point(139, 256);
     79      this.xAxisLabel.Location = new System.Drawing.Point(438, 277);
    7880      this.xAxisLabel.Name = "xAxisLabel";
    7981      this.xAxisLabel.Size = new System.Drawing.Size(62, 13);
     
    106108            | System.Windows.Forms.AnchorStyles.Left)
    107109            | System.Windows.Forms.AnchorStyles.Right)));
    108       chartArea1.Name = "ChartArea1";
    109       this.chart.ChartAreas.Add(chartArea1);
     110      chartArea2.Name = "ChartArea1";
     111      this.chart.ChartAreas.Add(chartArea2);
    110112      this.chart.Location = new System.Drawing.Point(6, 30);
    111113      this.chart.Name = "chart";
    112       series1.ChartArea = "ChartArea1";
    113       series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.BoxPlot;
    114       series1.IsVisibleInLegend = false;
    115       series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
    116       series1.Name = "DataSeries";
    117       series1.YValuesPerPoint = 6;
    118       this.chart.Series.Add(series1);
    119       this.chart.Size = new System.Drawing.Size(534, 217);
     114      series2.ChartArea = "ChartArea1";
     115      series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.BoxPlot;
     116      series2.IsVisibleInLegend = false;
     117      series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
     118      series2.Name = "DataSeries";
     119      series2.YValuesPerPoint = 6;
     120      this.chart.Series.Add(series2);
     121      this.chart.Size = new System.Drawing.Size(833, 238);
    120122      this.chart.TabIndex = 17;
    121123      this.chart.Text = "chart";
     
    127129      this.noRunsLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    128130      this.noRunsLabel.AutoSize = true;
    129       this.noRunsLabel.Location = new System.Drawing.Point(212, 122);
     131      this.noRunsLabel.Location = new System.Drawing.Point(361, 133);
    130132      this.noRunsLabel.Name = "noRunsLabel";
    131133      this.noRunsLabel.Size = new System.Drawing.Size(138, 13);
     
    142144      // splitContainer.Panel1
    143145      //
     146      this.splitContainer.Panel1.Controls.Add(this.hypergeometricCheckBox);
     147      this.splitContainer.Panel1.Controls.Add(this.label1);
     148      this.splitContainer.Panel1.Controls.Add(this.RecalculateButton);
    144149      this.splitContainer.Panel1.Controls.Add(this.sampleSizeTextBox);
    145       this.splitContainer.Panel1.Controls.Add(this.xAxisComboBox);
     150      this.splitContainer.Panel1.Controls.Add(this.xAxisTextBox);
    146151      this.splitContainer.Panel1.Controls.Add(this.defineSampleSizeButton);
    147152      this.splitContainer.Panel1.Controls.Add(this.showStatisticsCheckBox);
     
    155160      //
    156161      this.splitContainer.Panel2.Controls.Add(this.statisticsGroupBox);
    157       this.splitContainer.Size = new System.Drawing.Size(543, 416);
    158       this.splitContainer.SplitterDistance = 277;
     162      this.splitContainer.Size = new System.Drawing.Size(851, 447);
     163      this.splitContainer.SplitterDistance = 297;
    159164      this.splitContainer.TabIndex = 23;
    160165      //
     166      // hypergeometricCheckBox
     167      //
     168      this.hypergeometricCheckBox.AutoSize = true;
     169      this.hypergeometricCheckBox.Location = new System.Drawing.Point(332, 7);
     170      this.hypergeometricCheckBox.Name = "hypergeometricCheckBox";
     171      this.hypergeometricCheckBox.Size = new System.Drawing.Size(100, 17);
     172      this.hypergeometricCheckBox.TabIndex = 28;
     173      this.hypergeometricCheckBox.Text = "Hypergeometric";
     174      this.hypergeometricCheckBox.UseVisualStyleBackColor = true;
     175      this.hypergeometricCheckBox.CheckedChanged += new System.EventHandler(this.hypergeometricCheckBox_CheckedChanged);
     176      //
     177      // label1
     178      //
     179      this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     180      this.label1.AutoSize = true;
     181      this.label1.Location = new System.Drawing.Point(566, 6);
     182      this.label1.Name = "label1";
     183      this.label1.Size = new System.Drawing.Size(143, 13);
     184      this.label1.TabIndex = 26;
     185      this.label1.Text = "Recommended Sample Size:";
     186      //
     187      // RecalculateButton
     188      //
     189      this.RecalculateButton.Location = new System.Drawing.Point(251, 3);
     190      this.RecalculateButton.Name = "RecalculateButton";
     191      this.RecalculateButton.Size = new System.Drawing.Size(75, 23);
     192      this.RecalculateButton.TabIndex = 27;
     193      this.RecalculateButton.Text = "Recalculate";
     194      this.RecalculateButton.UseVisualStyleBackColor = true;
     195      this.RecalculateButton.Click += new System.EventHandler(this.RecalculateButton_Click);
     196      //
    161197      // sampleSizeTextBox
    162198      //
    163       this.sampleSizeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    164             | System.Windows.Forms.AnchorStyles.Right)));
    165       this.sampleSizeTextBox.Location = new System.Drawing.Point(400, 3);
     199      this.sampleSizeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     200      this.sampleSizeTextBox.Location = new System.Drawing.Point(724, 3);
    166201      this.sampleSizeTextBox.Name = "sampleSizeTextBox";
    167202      this.sampleSizeTextBox.ReadOnly = true;
    168       this.sampleSizeTextBox.Size = new System.Drawing.Size(140, 20);
     203      this.sampleSizeTextBox.Size = new System.Drawing.Size(124, 20);
    169204      this.sampleSizeTextBox.TabIndex = 26;
    170205      //
    171       // xAxisComboBox
    172       //
    173       this.xAxisComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    174       this.xAxisComboBox.Location = new System.Drawing.Point(207, 253);
    175       this.xAxisComboBox.Name = "xAxisComboBox";
    176       this.xAxisComboBox.Size = new System.Drawing.Size(238, 20);
    177       this.xAxisComboBox.TabIndex = 25;
    178       this.xAxisComboBox.TextChanged += new System.EventHandler(this.xAxisComboBox_TextChanged);
     206      // xAxisTextBox
     207      //
     208      this.xAxisTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     209      this.xAxisTextBox.Location = new System.Drawing.Point(506, 274);
     210      this.xAxisTextBox.Name = "xAxisTextBox";
     211      this.xAxisTextBox.Size = new System.Drawing.Size(238, 20);
     212      this.xAxisTextBox.TabIndex = 25;
     213      this.xAxisTextBox.TextChanged += new System.EventHandler(this.xAxisTextBox_TextChanged);
    179214      //
    180215      // defineSampleSizeButton
    181216      //
    182217      this.defineSampleSizeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    183       this.defineSampleSizeButton.Location = new System.Drawing.Point(451, 252);
     218      this.defineSampleSizeButton.Location = new System.Drawing.Point(750, 273);
    184219      this.defineSampleSizeButton.Name = "defineSampleSizeButton";
    185220      this.defineSampleSizeButton.Size = new System.Drawing.Size(89, 21);
     
    196231      this.showStatisticsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
    197232      this.showStatisticsCheckBox.Image = HeuristicLab.Common.Resources.VSImageLibrary.Properties;
    198       this.showStatisticsCheckBox.Location = new System.Drawing.Point(6, 245);
     233      this.showStatisticsCheckBox.Location = new System.Drawing.Point(6, 267);
    199234      this.showStatisticsCheckBox.Name = "showStatisticsCheckBox";
    200235      this.showStatisticsCheckBox.Size = new System.Drawing.Size(24, 24);
     
    212247      this.statisticsGroupBox.Location = new System.Drawing.Point(3, 3);
    213248      this.statisticsGroupBox.Name = "statisticsGroupBox";
    214       this.statisticsGroupBox.Size = new System.Drawing.Size(534, 129);
     249      this.statisticsGroupBox.Size = new System.Drawing.Size(833, 141);
    215250      this.statisticsGroupBox.TabIndex = 1;
    216251      this.statisticsGroupBox.TabStop = false;
     
    227262      this.statisticsMatrixView.ShowRowsAndColumnsTextBox = false;
    228263      this.statisticsMatrixView.ShowStatisticalInformation = false;
    229       this.statisticsMatrixView.Size = new System.Drawing.Size(528, 110);
     264      this.statisticsMatrixView.Size = new System.Drawing.Size(827, 122);
    230265      this.statisticsMatrixView.TabIndex = 0;
    231       //
    232       // label1
    233       //
    234       this.label1.AutoSize = true;
    235       this.label1.Location = new System.Drawing.Point(251, 6);
    236       this.label1.Name = "label1";
    237       this.label1.Size = new System.Drawing.Size(143, 13);
    238       this.label1.TabIndex = 26;
    239       this.label1.Text = "Recommended Sample Size:";
    240266      //
    241267      // SampleSizeInfluenceView
     
    244270      this.BackColor = System.Drawing.SystemColors.Window;
    245271      this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    246       this.Controls.Add(this.label1);
    247272      this.Controls.Add(this.splitContainer);
    248273      this.Name = "SampleSizeInfluenceView";
    249       this.Size = new System.Drawing.Size(543, 416);
     274      this.Size = new System.Drawing.Size(851, 447);
    250275      ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
    251276      this.splitContainer.Panel1.ResumeLayout(false);
     
    256281      this.statisticsGroupBox.ResumeLayout(false);
    257282      this.ResumeLayout(false);
    258       this.PerformLayout();
    259283
    260284    }
     
    273297    protected System.Windows.Forms.CheckBox showStatisticsCheckBox;
    274298    private System.Windows.Forms.Button defineSampleSizeButton;
    275     private System.Windows.Forms.TextBox xAxisComboBox;
     299    private System.Windows.Forms.TextBox xAxisTextBox;
    276300    private System.Windows.Forms.Label label1;
    277301    private System.Windows.Forms.TextBox sampleSizeTextBox;
     302    private System.Windows.Forms.Button RecalculateButton;
     303    private System.Windows.Forms.CheckBox hypergeometricCheckBox;
    278304  }
    279305}
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.cs

    r11378 r11670  
    208208    }
    209209
    210     private void UpdateSampleSizes() {
     210    private void UpdateSampleSizes(bool forceUpdate = false) {
    211211      string selectedYAxis = (string)this.yAxisComboBox.SelectedItem;
    212212
    213       if (selectedYAxis != null && xAxisComboBox.Text.Trim() == string.Empty) {
     213      if (selectedYAxis != null && (xAxisTextBox.Text.Trim() == string.Empty || forceUpdate)) {
     214        xAxisTextBox.Clear();
    214215        List<double> values = new List<double>();
    215216        foreach (IRun run in Content.Where(x => x.Visible)) {
     
    221222
    222223        if (values.Count() > 0) {
    223           xAxisComboBox.Text = "1; ";
    224           xAxisComboBox.Text += ((int)(values.Count() / 4)).ToString() + "; ";
    225           xAxisComboBox.Text += ((int)(values.Count() / 2)).ToString() + "; ";
    226           xAxisComboBox.Text += ((int)(values.Count() / 4 * 3)).ToString() + "; ";
    227           xAxisComboBox.Text += ((int)(values.Count())).ToString();
     224          if (hypergeometricCheckBox.Checked) {
     225            xAxisTextBox.Text += ((int)(values.Count() / 16)).ToString() + "; ";
     226            xAxisTextBox.Text += ((int)(values.Count() / 8)).ToString() + "; ";
     227            xAxisTextBox.Text += ((int)(values.Count() / 4)).ToString();
     228          } else {
     229            xAxisTextBox.Text += ((int)(values.Count() / 4)).ToString() + "; ";
     230            xAxisTextBox.Text += ((int)(values.Count() / 2)).ToString() + "; ";
     231            xAxisTextBox.Text += ((int)(values.Count() / 4 * 3)).ToString() + "; ";
     232            xAxisTextBox.Text += ((int)(values.Count())).ToString();
     233          }
    228234        }
    229235      }
     
    232238    private void UpdateComboBoxes() {
    233239      string selectedYAxis = (string)this.yAxisComboBox.SelectedItem;
    234       this.xAxisComboBox.Text = string.Empty;
     240      this.xAxisTextBox.Text = string.Empty;
    235241      this.yAxisComboBox.Items.Clear();
    236242      if (Content != null) {
     
    252258      if (Content != null) {
    253259        var usableRuns = Content.Where(r => r.Visible).ToList();
    254         Random rand = new Random();
    255 
    256         List<int> groupSizes = ParseGroupSizesFromText(xAxisComboBox.Text);
    257         foreach (int gs in groupSizes) {
    258           int idx = gs;
    259           List<IRun> runGroup = new List<IRun>();
    260           if (idx > usableRuns.Count()) {
    261             idx = usableRuns.Count();
    262           }
    263 
    264           for (int i = 0; i < idx; i++) {
    265             int r = rand.Next(usableRuns.Count());
    266             runGroup.Add(usableRuns[r]);
    267           }
    268           runGroup.ForEach(x => AddDataPoint(x, idx));
     260        List<int> groupSizes = ParseGroupSizesFromText(xAxisTextBox.Text);
     261
     262        if (hypergeometricCheckBox.Checked) {
     263          CalculateGroupsHypergeometric(usableRuns, groupSizes);
     264        } else {
     265          CalculateGroups(usableRuns, groupSizes);
    269266        }
    270267
     
    285282      }
    286283      UpdateNoRunsVisibleLabel();
     284    }
     285
     286    private void CalculateGroups(List<IRun> usableRuns, List<int> groupSizes) {
     287      Random rand = new Random();
     288
     289      foreach (int gs in groupSizes) {
     290        int idx = gs;
     291        List<IRun> runGroup = new List<IRun>();
     292        if (idx > usableRuns.Count()) {
     293          idx = usableRuns.Count();
     294        }
     295
     296        for (int i = 0; i < idx; i++) {
     297          int r = rand.Next(usableRuns.Count());
     298          runGroup.Add(usableRuns[r]);
     299        }
     300        runGroup.ForEach(x => AddDataPoint(x, idx));
     301      }
     302    }
     303
     304    private void CalculateGroupsHypergeometric(List<IRun> usableRuns, List<int> groupSizes) {
     305      Random rand = new Random();
     306      var runs = new List<IRun>(usableRuns);
     307
     308      foreach (int gs in groupSizes) {
     309        int idx = gs;
     310        List<IRun> runGroup = new List<IRun>();
     311        if (idx > runs.Count()) {
     312          idx = runs.Count();
     313        }
     314
     315        for (int i = 0; i < idx; i++) {
     316          int r = rand.Next(runs.Count());
     317          runGroup.Add(runs[r]);
     318          runs.Remove(runs[r]);
     319        }
     320        runGroup.ForEach(x => AddDataPoint(x, idx));
     321      }
    287322    }
    288323
     
    333368        if (datapoint != null) {
    334369          IRun run = (IRun)datapoint.Tag;
    335           string selectedAxis = xAxisComboBox.Text;
     370          string selectedAxis = xAxisTextBox.Text;
    336371          IItem value = null;
    337372
     
    482517        splitContainer.Panel2Collapsed = true;
    483518      }
     519    }
     520
     521    private void RecalculateButton_Click(object sender, EventArgs e) {
     522      UpdateDataPoints();
     523    }
     524
     525    private void hypergeometricCheckBox_CheckedChanged(object sender, EventArgs e) {
     526      UpdateSampleSizes(true);
     527      UpdateDataPoints();
    484528    }
    485529
     
    569613    private void defineSampleSizeButton_Click(object sender, EventArgs e) {
    570614      int min = 0, max = 0, step = 1;
    571       var groupSizes = ParseGroupSizesFromText(xAxisComboBox.Text);
     615      var groupSizes = ParseGroupSizesFromText(xAxisTextBox.Text);
    572616      if (groupSizes.Count() > 0) {
    573617        min = groupSizes.Min();
     
    582626            newVals += v + "; ";
    583627          }
    584           xAxisComboBox.Text = newVals;
    585         }
    586       }
    587     }
    588 
    589     private void xAxisComboBox_TextChanged(object sender, EventArgs e) {
    590       var result = ParseGroupSizesFromText(xAxisComboBox.Text, false);
     628          xAxisTextBox.Text = newVals;
     629        }
     630      }
     631    }
     632
     633    private void xAxisTextBox_TextChanged(object sender, EventArgs e) {
     634      var result = ParseGroupSizesFromText(xAxisTextBox.Text, false);
    591635
    592636      if (seriesCache.Count() == result.Count()) {
Note: See TracChangeset for help on using the changeset viewer.