Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.cs	(revision 8860)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.cs	(revision 8861)
@@ -23,5 +23,5 @@
 using System.Linq;
 using System.Windows.Forms;
-using HeuristicLab.Analysis;
+using HeuristicLab.Data;
 using HeuristicLab.MainForm;
 using HeuristicLab.MainForm.WindowsForms;
@@ -33,5 +33,5 @@
   public abstract partial class AbstractFeatureCorrelationView : AsynchronousContentView {
     protected FeatureCorrelationCalculator fcc;
-    protected HeatMap currentCorrelation;
+    protected DoubleMatrix currentCorrelation;
 
     public new DataAnalysisProblemData Content {
@@ -72,4 +72,6 @@
         CalculateCorrelation();
       } else {
+        dataView.Maximum = 0;
+        dataView.Minimum = 0;
         dataView.Content = null;
         dataView.ResetVisibility();
@@ -98,8 +100,11 @@
 
     protected void UpdateDataView() {
-      maximumLabel.Text = currentCorrelation.Maximum.ToString();
-      minimumLabel.Text = currentCorrelation.Minimum.ToString();
+      IDependencyCalculator calc = (IDependencyCalculator)CorrelationCalcComboBox.SelectedValue;
+      maximumLabel.Text = calc.Maximum.ToString();
+      minimumLabel.Text = calc.Minimum.ToString();
 
       currentCorrelation.SortableView = true;
+      dataView.Maximum = calc.Maximum;
+      dataView.Minimum = calc.Minimum;
       dataView.Content = currentCorrelation;
       dataView.Enabled = true;
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/EnhancedStringConvertibleMatrixView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/EnhancedStringConvertibleMatrixView.cs	(revision 8860)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/EnhancedStringConvertibleMatrixView.cs	(revision 8861)
@@ -25,6 +25,6 @@
 using System.Linq;
 using System.Windows.Forms;
-using HeuristicLab.Analysis;
 using HeuristicLab.Common;
+using HeuristicLab.Data;
 using HeuristicLab.Data.Views;
 
@@ -39,6 +39,9 @@
     public IEnumerable<bool> RowVisibility { set { rowVisibility = value; } }
 
-    public new HeatMap Content {
-      get { return (HeatMap)base.Content; }
+    public double Maximum { get; set; }
+    public double Minimum { get; set; }
+
+    public new DoubleMatrix Content {
+      get { return (DoubleMatrix)base.Content; }
       set { base.Content = value; }
     }
@@ -94,5 +97,5 @@
 
       int rowIndex = virtualRowIndices[e.RowIndex];
-      Color backColor = GetDataPointColor(Content[rowIndex, e.ColumnIndex], Content.Minimum, Content.Maximum);
+      Color backColor = GetDataPointColor(Content[rowIndex, e.ColumnIndex], Minimum, Maximum);
       using (Brush backColorBrush = new SolidBrush(backColor)) {
         e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs	(revision 8860)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs	(revision 8861)
@@ -23,5 +23,4 @@
 using System.Collections.Generic;
 using System.Windows.Forms;
-using HeuristicLab.Analysis;
 using HeuristicLab.Data;
 using HeuristicLab.MainForm;
@@ -61,5 +60,5 @@
         } else {
           fcc.TryCancelCalculation();
-          SetNewCorrelation(corr, calc);
+          SetNewCorrelation(corr);
           UpdateDataView();
         }
@@ -67,10 +66,8 @@
     }
 
-    private void SetNewCorrelation(double[,] elements, IDependencyCalculator calc) {
-      DoubleRange range = calc.Interval;
-      HeatMap hm = new HeatMap(elements, "", range.End, range.Start);
-      hm.RowNames = Content.Dataset.DoubleVariables;
-      hm.ColumnNames = Content.Dataset.DoubleVariables;
-      currentCorrelation = hm;
+    private void SetNewCorrelation(double[,] elements) {
+      currentCorrelation = new DoubleMatrix(elements,
+                                            Content.Dataset.DoubleVariables,
+                                            Content.Dataset.DoubleVariables);
     }
 
@@ -80,5 +77,5 @@
       } else {
         correlationCache.SetCorrelation(e.Calculcator, e.Partition, e.Correlation);
-        SetNewCorrelation(e.Correlation, e.Calculcator);
+        SetNewCorrelation(e.Correlation);
         UpdateDataView();
       }
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs	(revision 8860)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs	(revision 8861)
@@ -24,5 +24,4 @@
 using System.Linq;
 using System.Windows.Forms;
-using HeuristicLab.Analysis;
 using HeuristicLab.Data;
 using HeuristicLab.MainForm;
@@ -101,13 +100,11 @@
         Array.Copy(elements, i * elements.GetLength(1), neededValues, i * neededValues.GetLength(1), frames + 1);
       }
-      SetNewCorrelation(neededValues, calc);
+      SetNewCorrelation(neededValues);
     }
 
-    private void SetNewCorrelation(double[,] elements, IDependencyCalculator calc) {
-      DoubleRange range = calc.Interval;
-      HeatMap hm = new HeatMap(elements, "", range.End, range.Start);
-      hm.RowNames = Content.Dataset.DoubleVariables;
-      hm.ColumnNames = Enumerable.Range(0, elements.GetLength(1)).Select(x => x.ToString());
-      currentCorrelation = hm;
+    private void SetNewCorrelation(double[,] elements) {
+      currentCorrelation = new DoubleMatrix(elements,
+                                            Enumerable.Range(0, elements.GetLength(1)).Select(x => x.ToString()),
+                                            Content.Dataset.DoubleVariables);
     }
 
@@ -117,5 +114,5 @@
       } else {
         correlationTimeframCache.SetTimeframeCorrelation(e.Calculcator, e.Partition, e.Variable, e.Correlation);
-        SetNewCorrelation(e.Correlation, e.Calculcator);
+        SetNewCorrelation(e.Correlation);
         UpdateDataView();
       }
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj	(revision 8860)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj	(revision 8861)
@@ -164,6 +164,9 @@
     <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisSolution.cs" />
     <Compile Include="OnlineCalculators\AutoCorrelationCalculator.cs" />
+    <Compile Include="OnlineCalculators\DependencyCalculator\HoeffdingsDependenceCalculator.cs" />
+    <Compile Include="OnlineCalculators\DependencyCalculator\PearsonsRDependenceCalculator.cs" />
+    <Compile Include="OnlineCalculators\DependencyCalculator\PearsonsRSquaredDependenceCalculator.cs" />
+    <Compile Include="OnlineCalculators\DependencyCalculator\SpearmansRankCorrelationCoefficientCalculator.cs" />
     <Compile Include="OnlineCalculators\OnlineBoundedMeanSquaredErrorCalculator.cs" />
-    <Compile Include="OnlineCalculators\HoeffdingsDependenceCalculator.cs" />
     <Compile Include="OnlineCalculators\OnlineDirectionalSymmetryCalculator.cs" />
     <Compile Include="OnlineCalculators\OnlineMaxAbsoluteErrorCalculator.cs" />
@@ -207,7 +210,4 @@
     <Compile Include="OnlineCalculators\OnlineTheilsUStatisticCalculator.cs" />
     <Compile Include="OnlineCalculators\OnlineWeightedDirectionalSymmetryCalculator.cs" />
-    <Compile Include="OnlineCalculators\PearsonsRDependenceCalculator.cs" />
-    <Compile Include="OnlineCalculators\PearsonsRSquaredDependenceCalculator.cs" />
-    <Compile Include="OnlineCalculators\SpearmansRankCorrelationCoefficientCalculator.cs" />
     <Compile Include="Plugin.cs" />
     <Compile Include="Implementation\Classification\ThresholdCalculators\AccuracyMaximizationThresholdCalculator.cs" />
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDependencyCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDependencyCalculator.cs	(revision 8860)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDependencyCalculator.cs	(revision 8861)
@@ -21,9 +21,9 @@
 
 using System.Collections.Generic;
-using HeuristicLab.Data;
 
 namespace HeuristicLab.Problems.DataAnalysis {
   public interface IDependencyCalculator {
-    DoubleRange Interval { get; }
+    double Maximum { get; }
+    double Minimum { get; }
     string Name { get; }
 
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/HoeffdingsDependenceCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/HoeffdingsDependenceCalculator.cs	(revision 8861)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/HoeffdingsDependenceCalculator.cs	(revision 8861)
@@ -0,0 +1,139 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Problems.DataAnalysis {
+  public class HoeffdingsDependenceCalculator : IDependencyCalculator {
+
+    public double Maximum { get { return 1.0; } }
+
+    public double Minimum { get { return -0.5; } }
+
+    public string Name { get { return "Hoeffdings Dependence"; } }
+
+    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
+      return HoeffdingsDependenceCalculator.CalculateHoeffdings(originalValues, estimatedValues, out errorState);
+    }
+
+    public static double CalculateHoeffdings(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
+      double d = HoeffD(originalValues, estimatedValues, out errorState);
+      if (errorState != OnlineCalculatorError.None) return double.NaN;
+      return d;
+    }
+
+    /// <summary>
+    /// computes Hoeffding's dependence coefficient. 
+    /// Source: hoeffd.r from R package hmisc http://cran.r-project.org/web/packages/Hmisc/index.html
+    /// </summary>
+    private static double HoeffD(IEnumerable<double> xs, IEnumerable<double> ys, out OnlineCalculatorError errorState) {
+      double[] rx = TiedRank(xs);
+      double[] ry = TiedRank(ys);
+      if (rx.Length != ry.Length) throw new ArgumentException("The number of elements in xs and ys does not match");
+      double[] rxy = TiedRank(xs, ys);
+
+      int n = rx.Length;
+      double q = 0, r = 0, s = 0;
+      double scaling = 1.0 / (n * (n - 1));
+      for (int i = 0; i < n; i++) {
+        q += (rx[i] - 1) * (rx[i] - 2) * (ry[i] - 1) * (ry[i] - 2) * scaling;
+        r += (rx[i] - 2) * (ry[i] - 2) * rxy[i] * scaling;
+        s += rxy[i] * (rxy[i] - 1) * scaling;
+      }
+      errorState = OnlineCalculatorError.None;
+      // return 30.0 * (q - 2 * (n - 2) * r + (n - 2) * (n - 3) * s) / n / (n - 1) / (n - 2) / (n - 3) / (n - 4);
+      double t0 = q / (n - 2) / (n - 3) / (n - 4);
+      double t1 = 2 * r / (n - 3) / (n - 4);
+      double t2 = s / (n - 4);
+      return 30.0 * (t0 - t1 + t2);
+    }
+
+    private static double[] TiedRank(IEnumerable<double> xs) {
+      var xsArr = xs.ToArray();
+      var idx = Enumerable.Range(1, xsArr.Length).ToArray();
+      Array.Sort(xsArr, idx);
+      CRank(xsArr);
+      Array.Sort(idx, xsArr);
+      return xsArr;
+    }
+
+    /// <summary>
+    /// Calculates the joint rank with midranks for ties. Source: hoeffd.r from R package hmisc http://cran.r-project.org/web/packages/Hmisc/index.html
+    /// </summary>
+    /// <param name="xs"></param>
+    /// <param name="ys"></param>
+    /// <returns></returns>
+    private static double[] TiedRank(IEnumerable<double> xs, IEnumerable<double> ys) {
+      var xsArr = xs.ToArray();
+      var ysArr = ys.ToArray();
+      var r = new double[xsArr.Length];
+      int n = r.Length;
+      for (int i = 0; i < n; i++) {
+        var xi = xsArr[i];
+        var yi = ysArr[i];
+        double ri = 0.0;
+        for (int j = 0; j < n; j++) {
+          if (i != j) {
+            double cx;
+            if (xsArr[j] < xi) cx = 1.0;
+            else if (xsArr[j] > xi) cx = 0.0;
+            else cx = 0.5;  // eq
+            double cy;
+            if (ysArr[j] < yi) cy = 1.0;
+            else if (ysArr[j] > yi) cy = 0.0;
+            else cy = 0.5; // eq
+            ri = ri + cx * cy;
+          }
+        }
+        r[i] = ri;
+      }
+      return r;
+    }
+
+    /// <summary>
+    /// Calculates midranks. Source: Numerical Recipes in C. p 642
+    /// </summary>
+    /// <param name="w">Sorted array of elements, replaces the elements by their rank, including midranking of ties</param>
+    /// <returns></returns>
+    private static void CRank(double[] w) {
+      int i = 0;
+      int n = w.Length;
+      while (i < n - 1) {
+        if (w[i + 1] > w[i]) {    // w[i+1] must be larger or equal w[i] as w must be sorted
+          // not a tie
+          w[i] = i + 1;
+          i++;
+        } else {
+          int j;
+          for (j = i + 1; j < n && w[j] <= w[i]; j++) ; // how far does it go (<= effectively means == as w must be sorted, side-step equality for double values)
+          double rank = 1 + 0.5 * (i + j - 1);
+          int k;
+          for (k = i; k < j; k++) w[k] = rank; // set the rank for all tied entries
+          i = j;
+        }
+      }
+
+      if (i == n - 1) w[n - 1] = n;   // if the last element was not tied, this is its rank
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRDependenceCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRDependenceCalculator.cs	(revision 8861)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRDependenceCalculator.cs	(revision 8861)
@@ -0,0 +1,38 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  public class PearsonsRDependenceCalculator : IDependencyCalculator {
+
+    public double Maximum { get { return 1.0; } }
+
+    public double Minimum { get { return -1.0; } }
+
+    public string Name { get { return "Pearsons R"; } }
+
+    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
+      return Math.Sqrt(OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState));
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRSquaredDependenceCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRSquaredDependenceCalculator.cs	(revision 8861)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRSquaredDependenceCalculator.cs	(revision 8861)
@@ -0,0 +1,37 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  public class PearsonsRSquaredDependenceCalculator : IDependencyCalculator {
+
+    public double Maximum { get { return 1.0; } }
+
+    public double Minimum { get { return 0.0; } }
+
+    public string Name { get { return "Pearsons R Squared"; } }
+
+    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
+      return OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState);
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/SpearmansRankCorrelationCoefficientCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/SpearmansRankCorrelationCoefficientCalculator.cs	(revision 8861)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/SpearmansRankCorrelationCoefficientCalculator.cs	(revision 8861)
@@ -0,0 +1,53 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using System.Linq;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  public class SpearmansRankCorrelationCoefficientCalculator : IDependencyCalculator {
+
+    public double Maximum { get { return 1.0; } }
+
+    public double Minimum { get { return -1.0; } }
+
+    public string Name { get { return "Spearmans Rank"; } }
+
+    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
+      return SpearmansRankCorrelationCoefficientCalculator.CalculateSpearmansRank(originalValues, estimatedValues, out errorState);
+    }
+
+    public static double CalculateSpearmansRank(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
+      double rs = double.NaN;
+      try {
+        var original = originalValues.ToArray();
+        var estimated = estimatedValues.ToArray();
+        rs = alglib.basestat.spearmancorr2(original, estimated, original.Length);
+        errorState = OnlineCalculatorError.None;
+      }
+      catch (alglib.alglibexception) {
+        errorState = OnlineCalculatorError.InvalidValueAdded;
+      }
+
+      return rs;
+    }
+  }
+}
Index: unk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/HoeffdingsDependenceCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/HoeffdingsDependenceCalculator.cs	(revision 8860)
+++ 	(revision )
@@ -1,138 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2012 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;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Problems.DataAnalysis {
-  public class HoeffdingsDependenceCalculator : IDependencyCalculator {
-
-    public DoubleRange Interval { get { return new DoubleRange(1.0, -0.5); } }
-
-    public string Name { get { return "Hoeffdings Dependence"; } }
-
-    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
-      return HoeffdingsDependenceCalculator.CalculateHoeffdings(originalValues, estimatedValues, out errorState);
-    }
-
-    public static double CalculateHoeffdings(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
-      double d = HoeffD(originalValues, estimatedValues, out errorState);
-      if (errorState != OnlineCalculatorError.None) return double.NaN;
-      return d;
-    }
-
-    /// <summary>
-    /// computes Hoeffding's dependence coefficient. 
-    /// Source: hoeffd.r from R package hmisc http://cran.r-project.org/web/packages/Hmisc/index.html
-    /// </summary>
-    private static double HoeffD(IEnumerable<double> xs, IEnumerable<double> ys, out OnlineCalculatorError errorState) {
-      double[] rx = TiedRank(xs);
-      double[] ry = TiedRank(ys);
-      if (rx.Length != ry.Length) throw new ArgumentException("The number of elements in xs and ys does not match");
-      double[] rxy = TiedRank(xs, ys);
-
-      int n = rx.Length;
-      double q = 0, r = 0, s = 0;
-      double scaling = 1.0 / (n * (n - 1));
-      for (int i = 0; i < n; i++) {
-        q += (rx[i] - 1) * (rx[i] - 2) * (ry[i] - 1) * (ry[i] - 2) * scaling;
-        r += (rx[i] - 2) * (ry[i] - 2) * rxy[i] * scaling;
-        s += rxy[i] * (rxy[i] - 1) * scaling;
-      }
-      errorState = OnlineCalculatorError.None;
-      // return 30.0 * (q - 2 * (n - 2) * r + (n - 2) * (n - 3) * s) / n / (n - 1) / (n - 2) / (n - 3) / (n - 4);
-      double t0 = q / (n - 2) / (n - 3) / (n - 4);
-      double t1 = 2 * r / (n - 3) / (n - 4);
-      double t2 = s / (n - 4);
-      return 30.0 * (t0 - t1 + t2);
-    }
-
-    private static double[] TiedRank(IEnumerable<double> xs) {
-      var xsArr = xs.ToArray();
-      var idx = Enumerable.Range(1, xsArr.Length).ToArray();
-      Array.Sort(xsArr, idx);
-      CRank(xsArr);
-      Array.Sort(idx, xsArr);
-      return xsArr;
-    }
-
-    /// <summary>
-    /// Calculates the joint rank with midranks for ties. Source: hoeffd.r from R package hmisc http://cran.r-project.org/web/packages/Hmisc/index.html
-    /// </summary>
-    /// <param name="xs"></param>
-    /// <param name="ys"></param>
-    /// <returns></returns>
-    private static double[] TiedRank(IEnumerable<double> xs, IEnumerable<double> ys) {
-      var xsArr = xs.ToArray();
-      var ysArr = ys.ToArray();
-      var r = new double[xsArr.Length];
-      int n = r.Length;
-      for (int i = 0; i < n; i++) {
-        var xi = xsArr[i];
-        var yi = ysArr[i];
-        double ri = 0.0;
-        for (int j = 0; j < n; j++) {
-          if (i != j) {
-            double cx;
-            if (xsArr[j] < xi) cx = 1.0;
-            else if (xsArr[j] > xi) cx = 0.0;
-            else cx = 0.5;  // eq
-            double cy;
-            if (ysArr[j] < yi) cy = 1.0;
-            else if (ysArr[j] > yi) cy = 0.0;
-            else cy = 0.5; // eq
-            ri = ri + cx * cy;
-          }
-        }
-        r[i] = ri;
-      }
-      return r;
-    }
-
-    /// <summary>
-    /// Calculates midranks. Source: Numerical Recipes in C. p 642
-    /// </summary>
-    /// <param name="w">Sorted array of elements, replaces the elements by their rank, including midranking of ties</param>
-    /// <returns></returns>
-    private static void CRank(double[] w) {
-      int i = 0;
-      int n = w.Length;
-      while (i < n - 1) {
-        if (w[i + 1] > w[i]) {    // w[i+1] must be larger or equal w[i] as w must be sorted
-          // not a tie
-          w[i] = i + 1;
-          i++;
-        } else {
-          int j;
-          for (j = i + 1; j < n && w[j] <= w[i]; j++) ; // how far does it go (<= effectively means == as w must be sorted, side-step equality for double values)
-          double rank = 1 + 0.5 * (i + j - 1);
-          int k;
-          for (k = i; k < j; k++) w[k] = rank; // set the rank for all tied entries
-          i = j;
-        }
-      }
-
-      if (i == n - 1) w[n - 1] = n;   // if the last element was not tied, this is its rank
-    }
-  }
-}
Index: unk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/PearsonsRDependenceCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/PearsonsRDependenceCalculator.cs	(revision 8860)
+++ 	(revision )
@@ -1,37 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2012 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 HeuristicLab.Data;
-
-namespace HeuristicLab.Problems.DataAnalysis {
-  public class PearsonsRDependenceCalculator : IDependencyCalculator {
-
-    public DoubleRange Interval { get { return new DoubleRange(1.0, -1.0); } }
-
-    public string Name { get { return "Pearsons R"; } }
-
-    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
-      return Math.Sqrt(OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState));
-    }
-  }
-}
Index: unk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/PearsonsRSquaredDependenceCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/PearsonsRSquaredDependenceCalculator.cs	(revision 8860)
+++ 	(revision )
@@ -1,36 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2012 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.Collections.Generic;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Problems.DataAnalysis {
-  public class PearsonsRSquaredDependenceCalculator : IDependencyCalculator {
-
-    public DoubleRange Interval { get { return new DoubleRange(1.0, 0.0); } }
-
-    public string Name { get { return "Pearsons R Squared"; } }
-
-    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
-      return OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState);
-    }
-  }
-}
Index: unk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/SpearmansRankCorrelationCoefficientCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/SpearmansRankCorrelationCoefficientCalculator.cs	(revision 8860)
+++ 	(revision )
@@ -1,52 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2012 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.Collections.Generic;
-using System.Linq;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Problems.DataAnalysis {
-  public class SpearmansRankCorrelationCoefficientCalculator : IDependencyCalculator {
-
-    public DoubleRange Interval { get { return new DoubleRange(1.0, -1.0); } }
-
-    public string Name { get { return "Spearmans Rank"; } }
-
-    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
-      return SpearmansRankCorrelationCoefficientCalculator.CalculateSpearmansRank(originalValues, estimatedValues, out errorState);
-    }
-
-    public static double CalculateSpearmansRank(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
-      double rs = double.NaN;
-      try {
-        var original = originalValues.ToArray();
-        var estimated = estimatedValues.ToArray();
-        rs = alglib.basestat.spearmancorr2(original, estimated, original.Length);
-        errorState = OnlineCalculatorError.None;
-      }
-      catch (alglib.alglibexception) {
-        errorState = OnlineCalculatorError.InvalidValueAdded;
-      }
-
-      return rs;
-    }
-  }
-}
