Changeset 4233
- Timestamp:
- 08/16/10 19:17:13 (14 years ago)
- Location:
- branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/OnlineCovarianceEvaluator.cs
r4068 r4233 25 25 public class OnlineCovarianceEvaluator : IOnlineEvaluator { 26 26 27 private double originalMean, estimatedMean, Cn;27 private double xMean, yMean, Cn; 28 28 private int n; 29 29 public double Covariance { … … 47 47 n = 0; 48 48 Cn = 0.0; 49 originalMean = 0.0;50 estimatedMean = 0.0;49 xMean = 0.0; 50 yMean = 0.0; 51 51 } 52 52 53 public void Add(double original, double estimated) {54 if (double.IsNaN( estimated) || double.IsInfinity(estimated) ||55 double.IsNaN( original) || double.IsInfinity(original)) {53 public void Add(double x, double y) { 54 if (double.IsNaN(x) || double.IsInfinity(x) || 55 double.IsNaN(y) || double.IsInfinity(y)) { 56 56 throw new ArgumentException("Covariance is not defined for series containing NaN or infinity elements"); 57 57 } else { 58 58 n++; 59 59 // online calculation of tMean 60 originalMean = originalMean + (original - originalMean) / n; 61 double delta = estimated - estimatedMean; // delta = (y - yMean(n-1)) 62 estimatedMean = estimatedMean + delta / n; 60 61 xMean = xMean + (x - xMean) / n; 62 double deltaY = y - yMean; // delta = (y - yMean(n-1)) 63 yMean = yMean + deltaY / n; 63 64 64 65 // online calculation of covariance 65 Cn = Cn + delta * (original - originalMean); // C(n) = C(n-1) + (y - yMean(n-1)) (t - tMean(n))66 Cn = Cn + deltaY * (x - xMean); // C(n) = C(n-1) + (y - yMean(n-1)) (x - xMean(n)) 66 67 } 67 68 } -
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj
r4221 r4233 133 133 <Compile Include="Interfaces\IOnlineEvaluator.cs" /> 134 134 <Compile Include="MatrixExtensions.cs" /> 135 <Compile Include="Operators\CovariantParsimonyPressure.cs" /> 135 136 <Compile Include="Operators\DynamicDepthLimitInitializer.cs" /> 136 137 <Compile Include="Operators\DynOpEqHistogramInitializer.cs" />
Note: See TracChangeset
for help on using the changeset viewer.