Index: trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj	(revision 2421)
+++ trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj	(revision 2428)
@@ -82,6 +82,11 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="alglib\ap.cs" />
+    <Compile Include="alglib\correlation.cs" />
     <Compile Include="AnalyzerModel.cs" />
     <Compile Include="BestSolutionStorer.cs" />
+    <Compile Include="SimpleStableCorrelationCoefficientEvaluator.cs" />
+    <Compile Include="SimplePearsonCorrelationCoefficientEvaluator.cs" />
+    <Compile Include="SimpleSpearmansRankCorrelationCoefficientEvaluator.cs" />
     <Compile Include="DefaultModelAnalyzerOperators.cs" />
     <Compile Include="Matrix.cs" />
Index: trunk/sources/HeuristicLab.Modeling/3.2/ModelingResult.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/ModelingResult.cs	(revision 2421)
+++ trunk/sources/HeuristicLab.Modeling/3.2/ModelingResult.cs	(revision 2428)
@@ -43,4 +43,16 @@
     TestCoefficientOfDetermination,
 
+    TrainingPearsonsCorrelationCoefficient,
+    ValidationPearsonCorrelationCoefficient,
+    TestPearsonCorrelationCoefficient,
+
+    TrainingStablePearsonsCorrelationCoefficient,
+    ValidationStablePearsonCorrelationCoefficient,
+    TestStablePearsonCorrelationCoefficient,
+
+    TrainingSpearmansRankCorrelationCoefficient,
+    ValidationSpearmansRankCorrelationCoefficient,
+    TestSpearmansRankCorrelationCoefficient,
+
     TrainingVarianceAccountedFor,
     ValidationVarianceAccountedFor,
Index: trunk/sources/HeuristicLab.Modeling/3.2/ModelingResultCalculators.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/ModelingResultCalculators.cs	(revision 2421)
+++ trunk/sources/HeuristicLab.Modeling/3.2/ModelingResultCalculators.cs	(revision 2428)
@@ -59,4 +59,18 @@
           }
         },
+        { typeof(SimplePearsonCorrelationCoefficientEvaluator),
+          new ModelingResult[] {
+            ModelingResult.TrainingPearsonsCorrelationCoefficient,
+            ModelingResult.ValidationPearsonCorrlationCoefficent,
+            ModelingResult.TestPearsonCorrelationCoefficient
+          }
+        },
+        { typeof(SimpleSpearmansRankCorrelationCoefficientEvaluator),
+          new ModelingResult[] {
+            ModelingResult.TrainingSpearmansRankCorrelationCoefficient,
+            ModelingResult.ValidationSpearmansRankCorrelationCoefficient,
+            ModelingResult.TestSpearmansRankCorrelationCoefficient
+          }
+        },
         { typeof(SimpleVarianceAccountedForEvaluator),
           new ModelingResult[] {
@@ -148,4 +162,19 @@
       RegressionModelingResults[ModelingResult.ValidationCoefficientOfDetermination] = SimpleR2Evaluator.Calculate;
       RegressionModelingResults[ModelingResult.TestCoefficientOfDetermination] = SimpleR2Evaluator.Calculate;
+
+      //Pearson Correlation Coefficient
+      RegressionModelingResults[ModelingResult.TrainingPearsonsCorrelationCoefficient] = SimplePearsonCorrelationCoefficientEvaluator.Calculate;
+      RegressionModelingResults[ModelingResult.ValidationPearsonCorrelationCoefficient] = SimplePearsonCorrelationCoefficientEvaluator.Calculate;
+      RegressionModelingResults[ModelingResult.TestPearsonCorrelationCoefficient] = SimplePearsonCorrelationCoefficientEvaluator.Calculate;
+
+      //Stable Pearson Correlation Coefficient
+      RegressionModelingResults[ModelingResult.TrainingStablePearsonsCorrelationCoefficient] = SimpleStableCorrelationCoefficientEvaluator.Calculate;
+      RegressionModelingResults[ModelingResult.ValidationStablePearsonCorrelationCoefficient] = SimpleStableCorrelationCoefficientEvaluator.Calculate;
+      RegressionModelingResults[ModelingResult.TestStablePearsonCorrelationCoefficient] = SimpleStableCorrelationCoefficientEvaluator.Calculate;
+
+      //Spearman's rank correlation coefficient
+      RegressionModelingResults[ModelingResult.TrainingSpearmansRankCorrelationCoefficient] = SimpleSpearmansRankCorrelationCoefficientEvaluator.Calculate;
+      RegressionModelingResults[ModelingResult.ValidationSpearmansRankCorrelationCoefficient] = SimpleSpearmansRankCorrelationCoefficientEvaluator.Calculate;
+      RegressionModelingResults[ModelingResult.TestSpearmansRankCorrelationCoefficient] = SimpleSpearmansRankCorrelationCoefficientEvaluator.Calculate;
 
       //Variance accounted for
Index: trunk/sources/HeuristicLab.Modeling/3.2/SimplePearsonCorrelationCoefficientEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/SimplePearsonCorrelationCoefficientEvaluator.cs	(revision 2428)
+++ trunk/sources/HeuristicLab.Modeling/3.2/SimplePearsonCorrelationCoefficientEvaluator.cs	(revision 2428)
@@ -0,0 +1,37 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.Modeling {
+  public class SimplePearsonCorrelationCoefficientEvaluator : SimpleEvaluatorBase {
+
+    public override string OutputVariableName {
+      get {
+        return "R2";
+      }
+    }
+
+    public override double Evaluate(double[,] values) {
+      try {
+        return Calculate(values);
+      }
+      catch (ArgumentException) {
+        return double.NegativeInfinity;
+      }
+    }
+
+    public static double Calculate(double[,] values) {
+      double[] estimated = Matrix<double>.GetColumn(values, ESTIMATION_INDEX);
+      double[] original = Matrix<double>.GetColumn(values, ORIGINAL_INDEX);
+      double r = alglib.correlation.pearsoncorrelation(
+        ref estimated,
+        ref original,
+        values.GetLength(0));
+      return r * r;
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Modeling/3.2/SimpleR2Evaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/SimpleR2Evaluator.cs	(revision 2421)
+++ trunk/sources/HeuristicLab.Modeling/3.2/SimpleR2Evaluator.cs	(revision 2428)
@@ -48,7 +48,6 @@
           double target = values[i, ORIGINAL_INDEX];
           if (!double.IsNaN(target) && !double.IsInfinity(target)) {
-            target = target - targetMean;
-            target = target * target;
-            targetDeviationTotalSumOfSquares += target;
+            double targetDiff = target - targetMean;
+            targetDeviationTotalSumOfSquares += targetDiff * targetDiff;
           }
         }
Index: trunk/sources/HeuristicLab.Modeling/3.2/SimpleSpearmansRankCorrelationCoefficientEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/SimpleSpearmansRankCorrelationCoefficientEvaluator.cs	(revision 2428)
+++ trunk/sources/HeuristicLab.Modeling/3.2/SimpleSpearmansRankCorrelationCoefficientEvaluator.cs	(revision 2428)
@@ -0,0 +1,34 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.Modeling {
+  public class SimpleSpearmansRankCorrelationCoefficientEvaluator : SimpleEvaluatorBase {
+
+    public override string OutputVariableName {
+      get {
+        return "SpearmansRankCorrelationCoefficient";
+      }
+    }
+
+    public override double Evaluate(double[,] values) {
+      try {
+        return Calculate(values);
+      }
+      catch (ArgumentException) {
+        return double.NegativeInfinity;
+      }
+    }
+
+    public static double Calculate(double[,] values) {
+      return alglib.correlation.spearmanrankcorrelation(
+        Matrix<double>.GetColumn(values, ESTIMATION_INDEX),
+        Matrix<double>.GetColumn(values, ORIGINAL_INDEX),
+        values.GetLength(0));
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Modeling/3.2/SimpleStableCorrelationCoefficientEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/SimpleStableCorrelationCoefficientEvaluator.cs	(revision 2428)
+++ trunk/sources/HeuristicLab.Modeling/3.2/SimpleStableCorrelationCoefficientEvaluator.cs	(revision 2428)
@@ -0,0 +1,60 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.Modeling {
+  public class SimpleStableCorrelationCoefficientEvaluator : SimpleEvaluatorBase {
+
+    public override string OutputVariableName {
+      get {
+        return "R2";
+      }
+    }
+
+    public override double Evaluate(double[,] values) {
+      try {
+        return Calculate(values);
+      }
+      catch (ArgumentException) {
+        return double.NegativeInfinity;
+      }
+    }
+
+    public static double Calculate(double[,] values) {
+      double sum_sq_x = 0.0;
+      double sum_sq_y = 0.0;
+      double sum_coproduct = 0.0;
+      if (IsInvalidValue(values[0, ORIGINAL_INDEX]) || IsInvalidValue(values[0, ESTIMATION_INDEX])) {
+        throw new ArgumentException("Correlation coefficient is not defined for variables with NaN or infinity values.");
+      }
+      double mean_x = values[0, ORIGINAL_INDEX];
+      double mean_y = values[0, ESTIMATION_INDEX];
+      for (int i = 1; i < values.GetLength(0); i++) {
+        double sweep = (i - 1.0) / i;
+        if (IsInvalidValue(values[i, ORIGINAL_INDEX]) || IsInvalidValue(values[i, ESTIMATION_INDEX])) {
+          throw new ArgumentException("Correlation coefficient is not defined for variables with NaN or infinity values.");
+        }
+        double delta_x = values[i, ORIGINAL_INDEX] - mean_x;
+        double delta_y = values[i, ESTIMATION_INDEX] - mean_y;
+        sum_sq_x += delta_x * delta_x * sweep;
+        sum_sq_y += delta_y * delta_y * sweep;
+        sum_coproduct += delta_x * delta_y * sweep;
+        mean_x += delta_x / i;
+        mean_y += delta_y / i;
+      }
+      double pop_sd_x = Math.Sqrt(sum_sq_x / values.GetLength(0));
+      double pop_sd_y = Math.Sqrt(sum_sq_y / values.GetLength(0));
+      double cov_x_y = sum_coproduct / values.GetLength(0);
+      double r = cov_x_y / (pop_sd_x * pop_sd_y);
+      return r * r;
+    }
+
+    private static bool IsInvalidValue(double d) {
+      return double.IsNaN(d) || double.IsInfinity(d);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Modeling/3.2/alglib/ap.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/alglib/ap.cs	(revision 2428)
+++ trunk/sources/HeuristicLab.Modeling/3.2/alglib/ap.cs	(revision 2428)
@@ -0,0 +1,164 @@
+/*************************************************************************
+AP library
+Copyright (c) 2003-2009 Sergey Bochkanov (ALGLIB project).
+
+>>> LICENSE >>>
+This program 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 (www.fsf.org); either version 2 of the
+License, or (at your option) any later version.
+
+This program 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.
+
+A copy of the GNU General Public License is available at
+http://www.fsf.org/licensing/licenses
+
+>>> END OF LICENSE >>>
+*************************************************************************/
+namespace AP
+{
+    /********************************************************************
+    Class defining a complex number with double precision.
+    ********************************************************************/
+    public struct Complex
+    {
+        public double x;
+        public double y;
+
+        public Complex(double _x)
+        {
+            x = _x;
+            y = 0;
+        }
+        public Complex(double _x, double _y)
+        {
+            x = _x;
+            y = _y;
+        }
+        public static implicit operator Complex(double _x)
+        {
+            return new Complex(_x);
+        }
+        public static bool operator==(Complex lhs, Complex rhs)
+        {
+            return (lhs.x==rhs.x) & (lhs.y==rhs.y);
+        }
+        public static bool operator!=(Complex lhs, Complex rhs)
+        {
+            return (lhs.x!=rhs.x) | (lhs.y!=rhs.y);
+        }
+        public static Complex operator+(Complex lhs)
+        {
+            return lhs;
+        }
+        public static Complex operator-(Complex lhs)
+        {
+            return new Complex(-lhs.x,-lhs.y);
+        }
+        public static Complex operator+(Complex lhs, Complex rhs)
+        {
+            return new Complex(lhs.x+rhs.x,lhs.y+rhs.y);
+        }
+        public static Complex operator-(Complex lhs, Complex rhs)
+        {
+            return new Complex(lhs.x-rhs.x,lhs.y-rhs.y);
+        }
+        public static Complex operator*(Complex lhs, Complex rhs)
+        { 
+            return new Complex(lhs.x*rhs.x-lhs.y*rhs.y, lhs.x*rhs.y+lhs.y*rhs.x);
+        }
+        public static Complex operator/(Complex lhs, Complex rhs)
+        {
+            Complex result;
+            double e;
+            double f;
+            if( System.Math.Abs(rhs.y)<System.Math.Abs(rhs.x) )
+            {
+                e = rhs.y/rhs.x;
+                f = rhs.x+rhs.y*e;
+                result.x = (lhs.x+lhs.y*e)/f;
+                result.y = (lhs.y-lhs.x*e)/f;
+            }
+            else
+            {
+                e = rhs.x/rhs.y;
+                f = rhs.y+rhs.x*e;
+                result.x = (lhs.y+lhs.x*e)/f;
+                result.y = (-lhs.x+lhs.y*e)/f;
+            }
+            return result;
+        }
+    }    
+    
+	/********************************************************************
+	AP math namespace
+	********************************************************************/
+	public struct rcommstate
+	{
+		public int stage;
+		public int[] ia;
+		public bool[] ba;
+		public double[] ra;
+		public AP.Complex[] ca;
+	};
+
+	/********************************************************************
+    AP math namespace
+    ********************************************************************/
+    public class Math
+    {
+        public static System.Random RndObject = new System.Random(System.DateTime.Now.Millisecond);
+
+        public const double MachineEpsilon = 5E-16;
+        public const double MaxRealNumber = 1E300;
+        public const double MinRealNumber = 1E-300;
+        
+        public static double RandomReal()
+        {
+            double r = 0;
+            lock(RndObject){ r = RndObject.NextDouble(); }
+            return r;
+        }
+        public static int RandomInteger(int N)
+        {
+            int r = 0;
+            lock(RndObject){ r = RndObject.Next(N); }
+            return r;
+        }
+        public static double Sqr(double X)
+        {
+            return X*X;
+        }        
+        public static double AbsComplex(Complex z)
+        {
+            double w;
+            double xabs;
+            double yabs;
+            double v;
+    
+            xabs = System.Math.Abs(z.x);
+            yabs = System.Math.Abs(z.y);
+            w = xabs>yabs ? xabs : yabs;
+            v = xabs<yabs ? xabs : yabs; 
+            if( v==0 )
+                return w;
+            else
+            {
+                double t = v/w;
+                return w*System.Math.Sqrt(1+t*t);
+            }
+        }
+        public static Complex Conj(Complex z)
+        {
+            return new Complex(z.x, -z.y); 
+        }    
+        public static Complex CSqr(Complex z)
+        {
+            return new Complex(z.x*z.x-z.y*z.y, 2*z.x*z.y); 
+        }
+
+    }
+}
Index: trunk/sources/HeuristicLab.Modeling/3.2/alglib/correlation.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/alglib/correlation.cs	(revision 2428)
+++ trunk/sources/HeuristicLab.Modeling/3.2/alglib/correlation.cs	(revision 2428)
@@ -0,0 +1,272 @@
+/*************************************************************************
+Copyright (c) 2007, Sergey Bochkanov (ALGLIB project).
+
+>>> SOURCE LICENSE >>>
+This program 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 (www.fsf.org); either version 2 of the 
+License, or (at your option) any later version.
+
+This program 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.
+
+A copy of the GNU General Public License is available at
+http://www.fsf.org/licensing/licenses
+
+>>> END OF LICENSE >>>
+*************************************************************************/
+
+using System;
+
+namespace alglib
+{
+    public class correlation
+    {
+        /*************************************************************************
+        Pearson product-moment correlation coefficient
+
+        Input parameters:
+            X       -   sample 1 (array indexes: [0..N-1])
+            Y       -   sample 2 (array indexes: [0..N-1])
+            N       -   sample size.
+
+        Result:
+            Pearson product-moment correlation coefficient
+
+          -- ALGLIB --
+             Copyright 09.04.2007 by Bochkanov Sergey
+        *************************************************************************/
+        public static double pearsoncorrelation(ref double[] x,
+            ref double[] y,
+            int n)
+        {
+            double result = 0;
+            int i = 0;
+            double xmean = 0;
+            double ymean = 0;
+            double s = 0;
+            double xv = 0;
+            double yv = 0;
+            double t1 = 0;
+            double t2 = 0;
+
+            xv = 0;
+            yv = 0;
+            if( n<=1 )
+            {
+                result = 0;
+                return result;
+            }
+            
+            //
+            // Mean
+            //
+            xmean = 0;
+            ymean = 0;
+            for(i=0; i<=n-1; i++)
+            {
+                xmean = xmean+x[i];
+                ymean = ymean+y[i];
+            }
+            xmean = xmean/n;
+            ymean = ymean/n;
+            
+            //
+            // numerator and denominator
+            //
+            s = 0;
+            xv = 0;
+            yv = 0;
+            for(i=0; i<=n-1; i++)
+            {
+                t1 = x[i]-xmean;
+                t2 = y[i]-ymean;
+                xv = xv+AP.Math.Sqr(t1);
+                yv = yv+AP.Math.Sqr(t2);
+                s = s+t1*t2;
+            }
+            if( xv==0 | yv==0 )
+            {
+                result = 0;
+            }
+            else
+            {
+                result = s/(Math.Sqrt(xv)*Math.Sqrt(yv));
+            }
+            return result;
+        }
+
+
+        /*************************************************************************
+        Spearman's rank correlation coefficient
+
+        Input parameters:
+            X       -   sample 1 (array indexes: [0..N-1])
+            Y       -   sample 2 (array indexes: [0..N-1])
+            N       -   sample size.
+
+        Result:
+            Spearman's rank correlation coefficient
+
+          -- ALGLIB --
+             Copyright 09.04.2007 by Bochkanov Sergey
+        *************************************************************************/
+        public static double spearmanrankcorrelation(double[] x,
+            double[] y,
+            int n)
+        {
+            double result = 0;
+
+            x = (double[])x.Clone();
+            y = (double[])y.Clone();
+
+            rankx(ref x, n);
+            rankx(ref y, n);
+            result = pearsoncorrelation(ref x, ref y, n);
+            return result;
+        }
+
+
+        /*************************************************************************
+        Internal ranking subroutine
+        *************************************************************************/
+        private static void rankx(ref double[] x,
+            int n)
+        {
+            int i = 0;
+            int j = 0;
+            int k = 0;
+            int t = 0;
+            double tmp = 0;
+            int tmpi = 0;
+            double[] r = new double[0];
+            int[] c = new int[0];
+
+            
+            //
+            // Prepare
+            //
+            if( n<=1 )
+            {
+                x[0] = 1;
+                return;
+            }
+            r = new double[n-1+1];
+            c = new int[n-1+1];
+            for(i=0; i<=n-1; i++)
+            {
+                r[i] = x[i];
+                c[i] = i;
+            }
+            
+            //
+            // sort {R, C}
+            //
+            if( n!=1 )
+            {
+                i = 2;
+                do
+                {
+                    t = i;
+                    while( t!=1 )
+                    {
+                        k = t/2;
+                        if( r[k-1]>=r[t-1] )
+                        {
+                            t = 1;
+                        }
+                        else
+                        {
+                            tmp = r[k-1];
+                            r[k-1] = r[t-1];
+                            r[t-1] = tmp;
+                            tmpi = c[k-1];
+                            c[k-1] = c[t-1];
+                            c[t-1] = tmpi;
+                            t = k;
+                        }
+                    }
+                    i = i+1;
+                }
+                while( i<=n );
+                i = n-1;
+                do
+                {
+                    tmp = r[i];
+                    r[i] = r[0];
+                    r[0] = tmp;
+                    tmpi = c[i];
+                    c[i] = c[0];
+                    c[0] = tmpi;
+                    t = 1;
+                    while( t!=0 )
+                    {
+                        k = 2*t;
+                        if( k>i )
+                        {
+                            t = 0;
+                        }
+                        else
+                        {
+                            if( k<i )
+                            {
+                                if( r[k]>r[k-1] )
+                                {
+                                    k = k+1;
+                                }
+                            }
+                            if( r[t-1]>=r[k-1] )
+                            {
+                                t = 0;
+                            }
+                            else
+                            {
+                                tmp = r[k-1];
+                                r[k-1] = r[t-1];
+                                r[t-1] = tmp;
+                                tmpi = c[k-1];
+                                c[k-1] = c[t-1];
+                                c[t-1] = tmpi;
+                                t = k;
+                            }
+                        }
+                    }
+                    i = i-1;
+                }
+                while( i>=1 );
+            }
+            
+            //
+            // compute tied ranks
+            //
+            i = 0;
+            while( i<=n-1 )
+            {
+                j = i+1;
+                while( j<=n-1 )
+                {
+                    if( r[j]!=r[i] )
+                    {
+                        break;
+                    }
+                    j = j+1;
+                }
+                for(k=i; k<=j-1; k++)
+                {
+                    r[k] = 1+((double)(i+j-1))/(double)(2);
+                }
+                i = j;
+            }
+            
+            //
+            // back to x
+            //
+            for(i=0; i<=n-1; i++)
+            {
+                x[c[i]] = r[i];
+            }
+        }
+    }
+}
