Ignore:
Timestamp:
Feb 22, 2008, 6:01:15 PM (14 years ago)
Author:
Peter
Message:

refs #335 - Changed so Averager classes are consistently returning NaN when Averager is empty or for some other reason the estimation ends up with things like zero by zero division. Previously zero was returned from some functions and Nan from some functions. I did not change anythuing in NCC.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/AveragerPair.cc

    r1000 r1122  
    5151  double AveragerPair::ccc(void) const
    5252  {
    53     return ( (x_.variance() && y_.variance() && (x_.mean()-y_.mean()) ) ?
    54              ((2*covariance()) /
    55               ((x_.variance()+y_.variance()) +
    56                (x_.mean()-y_.mean())*(x_.mean()-y_.mean()))) : 0);
     53    return ((2*covariance()) /
     54            ((x_.variance()+y_.variance()) +
     55             (x_.mean()-y_.mean())*(x_.mean()-y_.mean())));
    5756  }
    5857
    5958  double AveragerPair::correlation(void) const
    60   { return ((x_.std()>0 && y_.std()>0) ?
    61             (covariance() / (x_.std()*y_.std()) ) : 0);
     59  { return covariance() / std::sqrt(x_.variance()*y_.variance());
    6260  }
    6361
    6462  double AveragerPair::covariance(void) const
    6563  {
    66     return (n()>1) ? (xy_ - x_.sum_x()*y_.mean()) / n(): 0;
     64    return (xy_ - x_.sum_x()*y_.mean()) / n();
    6765  }
    6866
Note: See TracChangeset for help on using the changeset viewer.