Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/04/11 15:38:16 (14 years ago)
Author:
mkommend
Message:

#1453: Renamed IOnlineEvaluator to IOnlineCalculator

File:
1 moved

Legend:

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

    r5941 r5942  
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class OnlinePearsonsRSquaredEvaluator : IOnlineEvaluator {
    28     private OnlineCovarianceEvaluator covEvaluator = new OnlineCovarianceEvaluator();
    29     private OnlineMeanAndVarianceCalculator sxEvaluator = new OnlineMeanAndVarianceCalculator();
    30     private OnlineMeanAndVarianceCalculator syEvaluator = new OnlineMeanAndVarianceCalculator();
     27  public class OnlinePearsonsRSquaredCalculator : IOnlineCalculator {
     28    private OnlineCovarianceCalculator covCalculator = new OnlineCovarianceCalculator();
     29    private OnlineMeanAndVarianceCalculator sxCalculator = new OnlineMeanAndVarianceCalculator();
     30    private OnlineMeanAndVarianceCalculator syCalculator = new OnlineMeanAndVarianceCalculator();
    3131
    3232    public double RSquared {
    3333      get {
    34         double xVar = sxEvaluator.PopulationVariance;
    35         double yVar = syEvaluator.PopulationVariance;
     34        double xVar = sxCalculator.PopulationVariance;
     35        double yVar = syCalculator.PopulationVariance;
    3636        if (xVar.IsAlmost(0.0) || yVar.IsAlmost(0.0)) {
    3737          return 0.0;
    3838        } else {
    39           double r = covEvaluator.Covariance / (Math.Sqrt(xVar) * Math.Sqrt(yVar));
     39          double r = covCalculator.Covariance / (Math.Sqrt(xVar) * Math.Sqrt(yVar));
    4040          return r * r;
    4141        }
     
    4343    }
    4444
    45     public OnlinePearsonsRSquaredEvaluator() { }
     45    public OnlinePearsonsRSquaredCalculator() { }
    4646
    47     #region IOnlineEvaluator Members
    48     public OnlineEvaluatorError ErrorState {
    49       get { return covEvaluator.ErrorState | sxEvaluator.PopulationVarianceErrorState | syEvaluator.PopulationVarianceErrorState; }
     47    #region IOnlineCalculator Members
     48    public OnlineCalculatorError ErrorState {
     49      get { return covCalculator.ErrorState | sxCalculator.PopulationVarianceErrorState | syCalculator.PopulationVarianceErrorState; }
    5050    }
    5151    public double Value {
     
    5353    }
    5454    public void Reset() {
    55       covEvaluator.Reset();
    56       sxEvaluator.Reset();
    57       syEvaluator.Reset();
     55      covCalculator.Reset();
     56      sxCalculator.Reset();
     57      syCalculator.Reset();
    5858    }
    5959
    6060    public void Add(double x, double y) {
    6161      // no need to check validity of values explicitly here as it is checked in all three evaluators
    62       covEvaluator.Add(x, y);
    63       sxEvaluator.Add(x);
    64       syEvaluator.Add(y);
     62      covCalculator.Add(x, y);
     63      sxCalculator.Add(x);
     64      syCalculator.Add(y);
    6565    }
    6666
    6767    #endregion
    6868
    69     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) {
     69    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    7070      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    7171      IEnumerator<double> secondEnumerator = second.GetEnumerator();
    72       OnlinePearsonsRSquaredEvaluator rSquaredEvaluator = new OnlinePearsonsRSquaredEvaluator();
     72      OnlinePearsonsRSquaredCalculator rSquaredCalculator = new OnlinePearsonsRSquaredCalculator();
    7373
    7474      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    7676        double estimated = secondEnumerator.Current;
    7777        double original = firstEnumerator.Current;
    78         rSquaredEvaluator.Add(original, estimated);
     78        rSquaredCalculator.Add(original, estimated);
    7979      }
    8080
     
    8383        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    8484      } else {
    85         errorState = rSquaredEvaluator.ErrorState;
    86         return rSquaredEvaluator.RSquared;
     85        errorState = rSquaredCalculator.ErrorState;
     86        return rSquaredCalculator.RSquared;
    8787      }
    8888    }
Note: See TracChangeset for help on using the changeset viewer.