Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/30/11 18:04:03 (14 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/OnlineLinearScalingParameterCalculator.cs

    r5818 r5894  
    3232    public double Alpha {
    3333      get {
    34         if (cnt < 2)
    35           return 0;
    36         else
    37           return targetMeanCalculator.Mean - Beta * originalMeanAndVarianceCalculator.Mean;
     34        return targetMeanCalculator.Mean - Beta * originalMeanAndVarianceCalculator.Mean;
    3835      }
    3936    }
     
    4441    public double Beta {
    4542      get {
    46         if (cnt < 2)
    47           return 1;
    48         else if (originalMeanAndVarianceCalculator.PopulationVariance.IsAlmost(0.0))
     43        if (originalMeanAndVarianceCalculator.PopulationVariance.IsAlmost(0.0))
    4944          return 1;
    5045        else
    5146          return originalTargetCovarianceEvaluator.Covariance / originalMeanAndVarianceCalculator.PopulationVariance;
     47      }
     48    }
     49
     50    public OnlineEvaluatorError ErrorState {
     51      get {
     52        return targetMeanCalculator.MeanErrorState | originalMeanAndVarianceCalculator.MeanErrorState |
     53          originalMeanAndVarianceCalculator.PopulationVarianceErrorState | originalTargetCovarianceEvaluator.ErrorState;
    5254      }
    5355    }
     
    9496    /// <param name="alpha">Additive constant for the linear scaling</param>
    9597    /// <param name="beta">Multiplicative factor for the linear scaling</param>
    96     public static void Calculate(IEnumerable<double> original, IEnumerable<double> target, out double alpha, out double beta) {
     98    /// <param name="errorState">Flag that indicates if errors occurred in the calculation of the linea scaling parameters.</param>
     99    public static void Calculate(IEnumerable<double> original, IEnumerable<double> target, out double alpha, out double beta, out OnlineEvaluatorError errorState) {
    97100      OnlineLinearScalingParameterCalculator calculator = new OnlineLinearScalingParameterCalculator();
    98101      IEnumerator<double> originalEnumerator = original.GetEnumerator();
     
    110113        throw new ArgumentException("Number of elements in original and target enumeration do not match.");
    111114      } else {
     115        errorState = calculator.ErrorState;
    112116        alpha = calculator.Alpha;
    113117        beta = calculator.Beta;
Note: See TracChangeset for help on using the changeset viewer.