Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionScaledMeanSquaredErrorEvaluator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionScaledMeanSquaredErrorEvaluator.cs	(revision 4026)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionScaledMeanSquaredErrorEvaluator.cs	(revision 4027)
@@ -114,10 +114,8 @@
       IEnumerator<double> originalEnumerator = original.GetEnumerator();
       IEnumerator<double> estimatedEnumerator = estimated.GetEnumerator();
-
+      OnlineMeanAndVarianceCalculator yVarianceCalculator = new OnlineMeanAndVarianceCalculator();
+      OnlineMeanAndVarianceCalculator tMeanCalculator = new OnlineMeanAndVarianceCalculator();
+      OnlineCovarianceEvaluator ytCovarianceEvaluator = new OnlineCovarianceEvaluator();
       int cnt = 0;
-      double tMean = 0;
-      double yMean = 0;
-      double Cn = 0;
-      double M2 = 0;
 
       while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) {
@@ -125,15 +123,9 @@
         double t = originalEnumerator.Current;
         if (IsValidValue(t) && IsValidValue(y)) {
+          tMeanCalculator.Add(t);
+          yVarianceCalculator.Add(y);
+          ytCovarianceEvaluator.Add(y, t);
+
           cnt++;
-          // online calculation of tMean
-          tMean = tMean + (t - tMean) / cnt;
-          double delta = y - yMean; // delta = (y - yMean(n-1))
-          yMean = yMean + delta / cnt;
-          
-          // online calculation of variance 
-          M2 = M2 + delta * (y - yMean); // M2(n) = M2(n-1) + (y - yMean(n-1)) (y - yMean(n))
-
-          // online calculation of covariance
-          Cn = Cn + delta * (t - tMean); // C(n) = C(n-1) + (y - yMean(n-1)) (t - tMean(n)) 
         }
       }
@@ -145,13 +137,10 @@
         beta = 1;
       } else {
-        // yVariance = M2 / cnt;
-        // ytCovariance = Cn / cnt;
-
-        if (M2.IsAlmost(0.0))
+        if (yVarianceCalculator.Variance.IsAlmost(0.0))
           beta = 1;
         else
-          beta = Cn / M2; // omit division by cnt
+          beta = ytCovarianceEvaluator.Covariance / yVarianceCalculator.Variance;
 
-        alpha = tMean - beta * yMean;
+        alpha = tMeanCalculator.Mean - beta * yVarianceCalculator.Mean;
       }
     }
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/OnlineCovarianceEvaluator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/OnlineCovarianceEvaluator.cs	(revision 4027)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/OnlineCovarianceEvaluator.cs	(revision 4027)
@@ -0,0 +1,77 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 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 System.Text;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+
+namespace HeuristicLab.Problems.DataAnalysis.Evaluators {
+  public class OnlineCovarianceEvaluator : IOnlineEvaluator {
+
+    private double originalMean, estimatedMean, Cn;
+    private int n;
+    public double Covariance {
+      get {
+        if (n < 1)
+          throw new InvalidOperationException("No elements");
+        else
+          return Cn / n;
+      }
+    }
+
+    public OnlineCovarianceEvaluator() {
+      Reset();
+    }
+
+    #region IOnlineEvaluator Members
+    public double Value {
+      get { return Covariance; }
+    }
+    public void Reset() {
+      n = 0;
+      Cn = 0.0;
+      originalMean = 0.0;
+      estimatedMean = 0.0;
+    }
+
+    public void Add(double original, double estimated) {
+      if (double.IsNaN(estimated) || double.IsInfinity(estimated) ||
+          double.IsNaN(original) || double.IsInfinity(original)) {
+        throw new ArgumentException("Covariance is not defined for series containing NaN or infinity elements");
+      } else {
+        n++;
+        // online calculation of tMean
+        originalMean = originalMean + (original - originalMean) / n;
+        double delta = estimated - estimatedMean; // delta = (y - yMean(n-1))
+        estimatedMean = estimatedMean + delta / n;
+
+        // online calculation of covariance
+        Cn = Cn + delta * (original - originalMean); // C(n) = C(n-1) + (y - yMean(n-1)) (t - tMean(n))       
+      }
+    }
+    #endregion
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj	(revision 4026)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj	(revision 4027)
@@ -84,4 +84,5 @@
     <None Include="HeuristicLabProblemsDataAnalysisPlugin.cs.frame" />
     <None Include="Properties\AssemblyInfo.frame" />
+    <Compile Include="Evaluators\OnlineCovarianceEvaluator.cs" />
     <Compile Include="Evaluators\OnlineMeanAndVarianceCalculator.cs" />
     <Compile Include="Evaluators\OnlineNormalizedMeanSquaredErrorEvaluator.cs" />
