Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/30/11 18:04:03 (13 years ago)
Author:
gkronber
Message:

#1453: Added an ErrorState property to online evaluators to indicate if the result value is valid or if there has been an error in the calculation. Adapted all classes that use one of the online evaluators to check this property.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineCovarianceEvaluator.cs

    r5845 r5894  
    3939
    4040    #region IOnlineEvaluator Members
     41    private OnlineEvaluatorError errorState;
     42    public OnlineEvaluatorError ErrorState {
     43      get { return errorState; }
     44    }
    4145    public double Value {
    4246      get { return Covariance; }
     
    4751      originalMean = 0.0;
    4852      estimatedMean = 0.0;
     53      errorState = OnlineEvaluatorError.InsufficientElementsAdded;
    4954    }
    5055
    5156    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)) {
    5760        n++;
     61        errorState = OnlineEvaluatorError.None;        // n >= 1
     62
    5863        // online calculation of tMean
    5964        originalMean = originalMean + (original - originalMean) / n;
     
    6772    #endregion
    6873
    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) {
    7075      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    7176      IEnumerator<double> secondEnumerator = second.GetEnumerator();
     
    8388        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    8489      } else {
     90        errorState = covarianceEvaluator.ErrorState;
    8591        return covarianceEvaluator.Covariance;
    8692      }
Note: See TracChangeset for help on using the changeset viewer.