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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.