Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/10/09 10:45:35 (15 years ago)
Author:
abeham
Message:

fixes a bug in MannWhitneyWilcoxonTest, regarding unsorted arrays (#573)
using a 2-tailed test is now properly used under the normal approximation method
some small enhancements to the control

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StatisticalAnalysis/3.2/MannWhitneyWilcoxonTestControl.cs

    r1530 r1548  
    4848    private double[] ConvertStringToArray(TextBox p) {
    4949      string t = p.Text;
    50       string[] s = t.Split(new char[] { ';' });
    51       double[] tmp = new double[s.Length];
    52       try {
    53         for (int i = 0; i < s.Length; i++) {
    54           tmp[i] = double.Parse(s[i]);
     50      string[] s = t.Split(new char[] { ';', ' ', '\t' });
     51      List<double> tmp = new List<double>();
     52      for (int i = 0; i < s.Length; i++) {
     53        try {
     54          double val = double.Parse(s[i]);
     55          tmp.Add(val);
    5556        }
     57        catch (FormatException) { }
    5658      }
    57       catch (FormatException) {
    58         return null;
    59       }
    60       return tmp;
     59      if (tmp.Count > 0) return tmp.ToArray();
     60      else return null;
    6161    }
    6262
     
    8181      double[] p2 = ConvertStringToArray(p2TextBox);
    8282      if (p1.Length > 20 || p2.Length > 20) {
    83         MessageBox.Show("Sample size is too large for exact calculation, do not use more than 20 samples in each population.");
    84         return;
     83        double[] tmp = new double[Math.Min(20, p1.Length)];
     84        for (int i = 0; i < Math.Min(20, p1.Length); i++) tmp[i] = p1[i];
     85        p1 = tmp;
     86        tmp = new double[Math.Min(20, p2.Length)];
     87        for (int i = 0; i < Math.Min(20, p2.Length); i++) tmp[i] = p2[i];
     88        p2 = tmp;
     89        MessageBox.Show("Caution: Sample size is too large for exact calculation. Only the first 20 samples are used for the test!");
    8590      }
    8691      double alpha = Double.Parse(alphaTextBox.Text);
Note: See TracChangeset for help on using the changeset viewer.