Index: /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/BonferroniHolm.cs
===================================================================
--- /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/BonferroniHolm.cs	(revision 9950)
+++ /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/BonferroniHolm.cs	(revision 9950)
@@ -0,0 +1,57 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace HeuristicLab.Analysis.Statistics {
+  public static class BonferroniHolm {
+    public static double[] Calculate(double globalAlpha, double[] pValues, out bool[] h) {
+      int k = pValues.Length;
+      double[] alphaNiveau = new double[k];
+      double[] adjustedPValues = new double[k];
+      bool[] decision = new bool[k];
+      Dictionary<int, double> pValuesIndizes = new Dictionary<int, double>();
+
+      for (int i = 0; i < k; i++) {
+        pValuesIndizes.Add(i, pValues[i]);
+      }
+      var sortedPValues = pValuesIndizes.OrderBy(x => x.Value);
+
+      for (int i = 1; i < k + 1; i++) {
+        alphaNiveau[i - 1] = globalAlpha / (k - i + 1);
+
+        if (i == 1) {
+          //true means reject
+          decision[sortedPValues.ElementAt(i - 1).Key] = sortedPValues.ElementAt(i - 1).Value < alphaNiveau[i - 1];
+          adjustedPValues[sortedPValues.ElementAt(i - 1).Key] = sortedPValues.ElementAt(i - 1).Value * (k - i + 1);
+        } else {
+          decision[sortedPValues.ElementAt(i - 1).Key] = decision[sortedPValues.ElementAt(i - 2).Key] ? (sortedPValues.ElementAt(i - 1).Value < alphaNiveau[i - 1]) : false;
+          adjustedPValues[sortedPValues.ElementAt(i - 1).Key] = Math.Max(adjustedPValues[sortedPValues.ElementAt(i - 2).Key], sortedPValues.ElementAt(i - 1).Value * (k - i + 1));
+        }
+      }
+
+      h = decision;
+      return adjustedPValues;
+    }
+  }
+}
Index: /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/HeuristicLab.Analysis.Statistics-3.3.csproj
===================================================================
--- /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/HeuristicLab.Analysis.Statistics-3.3.csproj	(revision 9949)
+++ /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/HeuristicLab.Analysis.Statistics-3.3.csproj	(revision 9950)
@@ -119,4 +119,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="BonferroniHolm.cs" />
     <Compile Include="ExpFitting.cs" />
     <Compile Include="IFitting.cs" />
Index: /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestingView.cs
===================================================================
--- /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestingView.cs	(revision 9949)
+++ /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestingView.cs	(revision 9950)
@@ -36,4 +36,5 @@
   [Content(typeof(RunCollection), false)]
   public sealed partial class StatisticalTestingView : ItemView {
+    private const double significanceLevel = 0.05;
     private double[][] data;
 
@@ -297,5 +298,5 @@
       double pval = KruskalWallis.Test(data);
       pValTextBox.Text = pval.ToString();
-      if (pval < 0.05) {
+      if (pval < significanceLevel) {
         this.Invoke(new Action(() => { groupCompLabel.Image = HeuristicLab.Analysis.Statistics.Resources.Default; }));
       } else {
@@ -314,5 +315,5 @@
 
       // p-value is below significance level and thus the null hypothesis (data is normally distributed) is rejected. 
-      if (res.Any(x => x < 0.05)) {
+      if (res.Any(x => x < significanceLevel)) {
         this.Invoke(new Action(() => { normalityLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Warning; }));
       } else {
@@ -355,5 +356,5 @@
         if (i != colIndex) {
           alglib.mannwhitneyutest(data[colIndex], data[colIndex].Length, data[i], data[i].Length, out mwuBothtails, out mwuLefttail, out mwuRighttail);
-          if (mwuBothtails > 0.05) {
+          if (mwuBothtails > significanceLevel) {
             cnt++;
           }
@@ -383,20 +384,39 @@
       }
 
-      DoubleMatrix pValsMatrix = new DoubleMatrix(5, stringConvertibleMatrixView.Content.Columns);
+      var rowNames = new string[] { "p-Value of Mann-Whitney U", "Adjusted p-Value of Mann-Whitney U", 
+            "p-Value of T-Test", "Adjusted p-Value of T-Test", "Necessary Sample Size for T-Test", "Cohen's d", "Hedges' g" };
+
+      DoubleMatrix pValsMatrix = new DoubleMatrix(rowNames.Length, stringConvertibleMatrixView.Content.Columns);
       pValsMatrix.ColumnNames = stringConvertibleMatrixView.Content.ColumnNames;
-      pValsMatrix.RowNames = new string[] { "p-Value of Mann-Whitney U", "p-Value of T-Test", "Necessary Sample Size for T-Test", "Cohen's d", "Hedges' g" };
+      pValsMatrix.RowNames = rowNames;
 
       double mwuBothtails;
       double mwuLefttail;
       double mwuRighttail;
-      double ttestLefttail;
+      double tTestLefttail;
+      double[] mwuPValues = new double[data.Length];
+      double[] tTestPValues = new double[data.Length];
+      bool[] decision = null;
+      double[] adjustedMwuPValues = null;
+      double[] adjustedTtestPValues = null;
+
       for (int i = 0; i < data.Length; i++) {
         alglib.mannwhitneyutest(data[colIndex], data[colIndex].Length, data[i], data[i].Length, out mwuBothtails, out mwuLefttail, out mwuRighttail);
-        ttestLefttail = TTest.Test(data[colIndex], data[i]);
-        pValsMatrix[0, i] = mwuBothtails;
-        pValsMatrix[1, i] = ttestLefttail;
-        pValsMatrix[2, i] = TTest.GetOptimalSampleSize(data[colIndex], data[i]);
-        pValsMatrix[3, i] = SampleSizeDetermination.CalculateCohensD(data[colIndex], data[i]);
-        pValsMatrix[4, i] = SampleSizeDetermination.CalculateHedgesG(data[colIndex], data[i]);
+        tTestLefttail = TTest.Test(data[colIndex], data[i]);
+        mwuPValues[i] = mwuBothtails;
+        tTestPValues[i] = tTestLefttail;
+      }
+
+      adjustedMwuPValues = BonferroniHolm.Calculate(significanceLevel, mwuPValues, out decision);
+      adjustedTtestPValues = BonferroniHolm.Calculate(significanceLevel, tTestPValues, out decision);
+
+      for (int i = 0; i < data.Length; i++) {
+        pValsMatrix[0, i] = mwuPValues[i];
+        pValsMatrix[1, i] = adjustedMwuPValues[i];
+        pValsMatrix[2, i] = tTestPValues[i];
+        pValsMatrix[3, i] = adjustedTtestPValues[i];
+        pValsMatrix[4, i] = TTest.GetOptimalSampleSize(data[colIndex], data[i]);
+        pValsMatrix[5, i] = SampleSizeDetermination.CalculateCohensD(data[colIndex], data[i]);
+        pValsMatrix[6, i] = SampleSizeDetermination.CalculateHedgesG(data[colIndex], data[i]);
       }
 
Index: /branches/StatisticalTesting/Statistics.UnitTests/BonferroniHolmUnitTest.cs
===================================================================
--- /branches/StatisticalTesting/Statistics.UnitTests/BonferroniHolmUnitTest.cs	(revision 9950)
+++ /branches/StatisticalTesting/Statistics.UnitTests/BonferroniHolmUnitTest.cs	(revision 9950)
@@ -0,0 +1,75 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Analysis.Statistics;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Statistics.UnitTests {
+  [TestClass]
+  public class BonferroniHolmUnitTest {
+    [TestMethod]
+    public void TestMethod1() {
+      /* example taken from 
+       * http://www.mathworks.com/matlabcentral/fileexchange/28303-bonferroni-holm-correction-for-multiple-comparisons
+       * 
+       * p = 0.56, 0.22, 0.001, 0.04, 0.01
+       * a = 0.05
+       * cor_p = 0.560, 0.440, 0.005, 0.120, 0.040
+       * h = 0, 0, 1, 0, 1
+       * 
+       */
+
+      double[] correctedPValues = new double[] { 0.56, 0.44, 0.005, 0.12, 0.04 };
+      double[] pVals = new[] { 0.56, 0.22, 0.001, 0.04, 0.01 };
+      bool[] h = new bool[] { false, false, true, false, true };
+      bool[] decision;
+
+      var result = BonferroniHolm.Calculate(0.05, pVals, out decision);
+
+      for (int i = 0; i < pVals.Length; i++) {
+        Assert.AreEqual(correctedPValues[i], result[i]);
+        Assert.AreEqual(h[i], decision[i]);
+      }
+    }
+
+    [TestMethod]
+    public void TestMethod2() {
+      /* example taken from 
+       * http://en.wikipedia.org/wiki/Holm-Bonferroni_method#Example
+       * 
+       * p = 0.01, 0.04, 0.03,  0.005
+       * a = 0.05
+       * h = 1, 0, 0, 1
+       * 
+       */
+
+      double[] pVals = new[] { 0.01, 0.04, 0.03, 0.005 };
+      bool[] h = new bool[] { true, false, false, true };
+      bool[] decision;
+
+      BonferroniHolm.Calculate(0.05, pVals, out decision);
+
+      for (int i = 0; i < pVals.Length; i++) {
+        Assert.AreEqual(h[i], decision[i]);
+      }
+    }
+  }
+}
Index: /branches/StatisticalTesting/Statistics.UnitTests/Statistics.UnitTests.csproj
===================================================================
--- /branches/StatisticalTesting/Statistics.UnitTests/Statistics.UnitTests.csproj	(revision 9949)
+++ /branches/StatisticalTesting/Statistics.UnitTests/Statistics.UnitTests.csproj	(revision 9950)
@@ -64,4 +64,5 @@
     <Compile Include="KruskalWallisUnitTests.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="BonferroniHolmUnitTest.cs" />
   </ItemGroup>
   <ItemGroup>
