Changeset 1122 for trunk/yat/statistics

Ignore:
Timestamp:
Feb 22, 2008, 6:01:15 PM (14 years ago)
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.

Location:
trunk/yat/statistics
Files:
7 edited

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

 r1000 #include #include namespace theplu { double Averager::cv(void) const { return x_ ? std()/mean() : 0; return std()/mean(); } double Averager::mean(void) const { return n_ ? x_/n_ : 0; return x_/n_; } double Averager::variance(double m) const { return n_ ? (xx_ - 2*m*x_ + m*m*n()) /n_ : 0; return (xx_ - 2*m*x_ + m*m*n()) /n_; } double Averager::variance(void) const { return n_>1 ? sum_xx_centered()/n_ : 0; return sum_xx_centered()/n_; } double Averager::variance_unbiased(void) const { return (n_>1) ? sum_xx_centered()/(n_-1) : 0; return (n_>1) ? sum_xx_centered()/(n_-1) : std::numeric_limits::quiet_NaN(); }
• trunk/yat/statistics/Averager.h

 r1000 double variance(double m) const; /// /// @brief The estimated variance /// /// The variance is calculated as \f$\frac{1}{N}\sum_i /// (x_i-m)^2 \f$, where \f$m \f$ is the mean. /// /// @return Estimation of variance /// /** \brief The estimated variance The variance is calculated as \f$\frac{1}{N}\sum_i (x_i-m)^2 \f$, where \f$m \f$ is the mean. \return Estimation of variance */ double variance(void) const;
• trunk/yat/statistics/AveragerPair.cc

 r1000 double AveragerPair::ccc(void) const { return ( (x_.variance() && y_.variance() && (x_.mean()-y_.mean()) ) ? ((2*covariance()) / ((x_.variance()+y_.variance()) + (x_.mean()-y_.mean())*(x_.mean()-y_.mean()))) : 0); return ((2*covariance()) / ((x_.variance()+y_.variance()) + (x_.mean()-y_.mean())*(x_.mean()-y_.mean()))); } double AveragerPair::correlation(void) const { return ((x_.std()>0 && y_.std()>0) ? (covariance() / (x_.std()*y_.std()) ) : 0); { return covariance() / std::sqrt(x_.variance()*y_.variance()); } double AveragerPair::covariance(void) const { return (n()>1) ? (xy_ - x_.sum_x()*y_.mean()) / n(): 0; return (xy_ - x_.sum_x()*y_.mean()) / n(); }
• trunk/yat/statistics/AveragerPair.h

 r1043 \f$\frac{\sum_i (x_i-m_x)(y_i-m_y)}{\sum_i (x_i-m_x)^2+\sum_i (y_i-m_y)^2 + n(m_x-m_y)^2} \f$ In case of a zero denominator - zero is returned. @return Concordence correlation coefficient.
• trunk/yat/statistics/AveragerPairWeighted.cc

 r1043 #include "AveragerPair.h" #include "Averager.h" #include "yat/classifier/DataLookup1D.h" #include "yat/classifier/DataLookupWeighted1D.h" #include double AveragerPairWeighted::correlation(void) const { return ( x_.variance()>0 && y_.variance()>0 ? covariance() / sqrt(x_.variance()*y_.variance()) : 0 ); return covariance() / sqrt(x_.variance()*y_.variance()); }
• trunk/yat/statistics/AveragerPairWeighted.h

 r1088 namespace theplu{ namespace yat{ namespace classifier{ class DataLookup1D; class DataLookupWeighted1D; } namespace statistics{ ///
• trunk/yat/statistics/AveragerWeighted.cc

 r1000 double AveragerWeighted::mean(void) const { return sum_w() ? sum_wx()/sum_w() : 0; return sum_wx()/sum_w(); }
Note: See TracChangeset for help on using the changeset viewer.