Index: /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/OnlineCovarianceEvaluator.cs
===================================================================
--- /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/OnlineCovarianceEvaluator.cs	(revision 4232)
+++ /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/OnlineCovarianceEvaluator.cs	(revision 4233)
@@ -25,5 +25,5 @@
   public class OnlineCovarianceEvaluator : IOnlineEvaluator {
 
-    private double originalMean, estimatedMean, Cn;
+    private double xMean, yMean, Cn;
     private int n;
     public double Covariance {
@@ -47,21 +47,22 @@
       n = 0;
       Cn = 0.0;
-      originalMean = 0.0;
-      estimatedMean = 0.0;
+      xMean = 0.0;
+      yMean = 0.0;
     }
 
-    public void Add(double original, double estimated) {
-      if (double.IsNaN(estimated) || double.IsInfinity(estimated) ||
-          double.IsNaN(original) || double.IsInfinity(original)) {
+    public void Add(double x, double y) {
+      if (double.IsNaN(x) || double.IsInfinity(x) ||
+          double.IsNaN(y) || double.IsInfinity(y)) {
         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;
+
+        xMean = xMean + (x - xMean) / n;
+        double deltaY = y - yMean; // delta = (y - yMean(n-1))
+        yMean = yMean + deltaY / n;
 
         // online calculation of covariance
-        Cn = Cn + delta * (original - originalMean); // C(n) = C(n-1) + (y - yMean(n-1)) (t - tMean(n))       
+        Cn = Cn + deltaY * (x - xMean); // C(n) = C(n-1) + (y - yMean(n-1)) (x - xMean(n))
       }
     }
Index: /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj
===================================================================
--- /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj	(revision 4232)
+++ /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj	(revision 4233)
@@ -133,4 +133,5 @@
     <Compile Include="Interfaces\IOnlineEvaluator.cs" />
     <Compile Include="MatrixExtensions.cs" />
+    <Compile Include="Operators\CovariantParsimonyPressure.cs" />
     <Compile Include="Operators\DynamicDepthLimitInitializer.cs" />
     <Compile Include="Operators\DynOpEqHistogramInitializer.cs" />
Index: /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/CovariantParsimonyPressure.cs
===================================================================
--- /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/CovariantParsimonyPressure.cs	(revision 4233)
+++ /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/CovariantParsimonyPressure.cs	(revision 4233)
@@ -0,0 +1,107 @@
+﻿#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.Linq;
+using alglib;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using System.Collections.Generic;
+using HeuristicLab.Problems.DataAnalysis.Evaluators;
+
+namespace HeuristicLab.Problems.DataAnalysis.Operators {
+  [Item("Covariant Parsimony Pressure", "Covariant Parsimony Pressure.")]
+  [StorableClass]
+  public class CovariantParsimonyPressure : SingleSuccessorOperator {
+    public IScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
+      get { return (IScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters["SymbolicExpressionTree"]; }
+    }
+    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
+      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
+    }
+    public ILookupParameter<BoolValue> MaximizationParameter {
+      get { return (ILookupParameter<BoolValue>)Parameters["Maximization"]; }
+    }
+    public IValueLookupParameter<DoubleValue> KParameter {
+      get { return (IValueLookupParameter<DoubleValue>)Parameters["K"]; }
+    }
+
+
+    public CovariantParsimonyPressure(bool deserializing) : base(deserializing) { }
+    public CovariantParsimonyPressure()
+      : base() {
+      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>("SymbolicExpressionTree"));
+      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality"));
+      Parameters.Add(new LookupParameter<BoolValue>("Maximization"));
+      Parameters.Add(new ValueLookupParameter<DoubleValue>("K", new DoubleValue(1.0)));
+    }
+
+    [StorableHook(Persistence.Default.CompositeSerializers.Storable.HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      if (!Parameters.ContainsKey("Maximization"))
+        Parameters.Add(new LookupParameter<BoolValue>("Maximization"));
+      if (!Parameters.ContainsKey("K"))
+        Parameters.Add(new ValueLookupParameter<DoubleValue>("K", new DoubleValue(1.0)));
+    }
+
+    public override IOperation Apply() {
+      var trees = SymbolicExpressionTreeParameter.ActualValue;
+      var qualities = QualityParameter.ActualValue;
+      var lengths = from tree in trees
+                    select tree.Size;
+      double k = KParameter.ActualValue.Value;
+
+      // calculate cov(f, l) and cov(l, l^k)
+      OnlineCovarianceEvaluator lengthFitnessCovEvaluator = new OnlineCovarianceEvaluator();
+      OnlineCovarianceEvaluator lengthAdjLengthCovEvaluator = new OnlineCovarianceEvaluator();
+      var lengthEnumerator = lengths.GetEnumerator();
+      var qualityEnumerator = qualities.GetEnumerator();
+      while (lengthEnumerator.MoveNext() & qualityEnumerator.MoveNext()) {
+        double fitness = qualityEnumerator.Current.Value;
+        if (!MaximizationParameter.ActualValue.Value) {
+          // use f = 1 / (1 + quality) for minimization problems
+          fitness = 1.0 / (1.0 + fitness);
+        }
+        lengthFitnessCovEvaluator.Add(lengthEnumerator.Current, fitness);
+        lengthAdjLengthCovEvaluator.Add(lengthEnumerator.Current, Math.Pow(lengthEnumerator.Current, k));
+      }
+
+      // c = cov(l, f) / cov(l, l^k)
+      double c = lengthFitnessCovEvaluator.Covariance / lengthAdjLengthCovEvaluator.Covariance;
+
+      // adjust fitness
+      bool maximization = MaximizationParameter.ActualValue.Value;
+
+      lengthEnumerator = lengths.GetEnumerator();
+      qualityEnumerator = qualities.GetEnumerator();
+      while (lengthEnumerator.MoveNext() & qualityEnumerator.MoveNext()) {
+        qualityEnumerator.Current.Value = qualityEnumerator.Current.Value - c * Math.Pow(lengthEnumerator.Current, k);
+      }
+
+      return base.Apply();
+    }
+  }
+}
