Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6095 for trunk/sources


Ignore:
Timestamp:
05/02/11 14:46:08 (13 years ago)
Author:
gkronber
Message:

#1498: added check for very small and very large values in mean/variance calculator to fix numeric instability problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAndVarianceCalculator.cs

    r5945 r6095  
    7373
    7474    public void Add(double x) {
    75       if (double.IsNaN(x) || double.IsInfinity(x) || (errorState & OnlineCalculatorError.InvalidValueAdded) > 0) {
     75      if (double.IsNaN(x) || double.IsInfinity(x) || x > 1E13 || x < -1E13 || (errorState & OnlineCalculatorError.InvalidValueAdded) > 0) {
    7676        errorState = errorState | OnlineCalculatorError.InvalidValueAdded;
    7777        varianceErrorState = errorState | OnlineCalculatorError.InvalidValueAdded;
     
    8484          errorState = errorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 1
    8585        } else {
     86
    8687          varianceErrorState = varianceErrorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 2
    8788          m_newM = m_oldM + (x - m_oldM) / n;
Note: See TracChangeset for help on using the changeset viewer.