Changeset 5894 for trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineCovarianceEvaluator.cs
- Timestamp:
- 03/30/11 18:04:03 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineCovarianceEvaluator.cs
r5845 r5894 39 39 40 40 #region IOnlineEvaluator Members 41 private OnlineEvaluatorError errorState; 42 public OnlineEvaluatorError ErrorState { 43 get { return errorState; } 44 } 41 45 public double Value { 42 46 get { return Covariance; } … … 47 51 originalMean = 0.0; 48 52 estimatedMean = 0.0; 53 errorState = OnlineEvaluatorError.InsufficientElementsAdded; 49 54 } 50 55 51 56 public void Add(double original, double estimated) { 52 if (double.IsNaN(estimated) || double.IsInfinity(estimated) || 53 double.IsNaN(original) || double.IsInfinity(original) || 54 double.IsNaN(Cn)) { 55 Cn = double.NaN; 56 } else { 57 if (double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(original) || double.IsInfinity(original)) { 58 errorState = errorState | OnlineEvaluatorError.InvalidValueAdded; 59 } else if (!errorState.HasFlag(OnlineEvaluatorError.InvalidValueAdded)) { 57 60 n++; 61 errorState = OnlineEvaluatorError.None; // n >= 1 62 58 63 // online calculation of tMean 59 64 originalMean = originalMean + (original - originalMean) / n; … … 67 72 #endregion 68 73 69 public static double Calculate(IEnumerable<double> first, IEnumerable<double> second ) {74 public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) { 70 75 IEnumerator<double> firstEnumerator = first.GetEnumerator(); 71 76 IEnumerator<double> secondEnumerator = second.GetEnumerator(); … … 83 88 throw new ArgumentException("Number of elements in first and second enumeration doesn't match."); 84 89 } else { 90 errorState = covarianceEvaluator.ErrorState; 85 91 return covarianceEvaluator.Covariance; 86 92 }
Note: See TracChangeset
for help on using the changeset viewer.