Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 4027

Ignore:
Timestamp:
07/12/10 18:46:59 (13 years ago)
Message:

Moved code for calculation of covariance from the scaled MSE evaluator into a separate online evaluator. #1081

Location:
trunk/sources
Files:
1 added
2 edited

Unmodified
Added
Removed
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionScaledMeanSquaredErrorEvaluator.cs

 r4001 IEnumerator originalEnumerator = original.GetEnumerator(); IEnumerator 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()) { 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)) } } 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; } }
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj

 r4022
Note: See TracChangeset for help on using the changeset viewer.