 Timestamp:
 Feb 22, 2008, 6:01:15 PM (15 years ago)
 Location:
 trunk/yat/statistics
 Files:

 7 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/statistics/Averager.cc
r1000 r1122 26 26 27 27 #include <cassert> 28 #include <limits> 28 29 29 30 namespace theplu { … … 56 57 double Averager::cv(void) const 57 58 { 58 return x_ ? std()/mean() : 0;59 return std()/mean(); 59 60 } 60 61 61 62 double Averager::mean(void) const 62 63 { 63 return n_ ? x_/n_ : 0;64 return x_/n_; 64 65 } 65 66 … … 113 114 double Averager::variance(double m) const 114 115 { 115 return n_ ? (xx_  2*m*x_ + m*m*n()) /n_ : 0;116 return (xx_  2*m*x_ + m*m*n()) /n_; 116 117 } 117 118 118 119 double Averager::variance(void) const 119 120 { 120 return n_>1 ? sum_xx_centered()/n_ : 0;121 return sum_xx_centered()/n_; 121 122 } 122 123 123 124 double Averager::variance_unbiased(void) const 124 125 { 125 return (n_>1) ? sum_xx_centered()/(n_1) : 0; 126 return (n_>1) ? sum_xx_centered()/(n_1) : 127 std::numeric_limits<double>::quiet_NaN(); 126 128 } 127 129 
trunk/yat/statistics/Averager.h
r1000 r1122 143 143 double variance(double m) const; 144 144 145 / //146 /// @brief The estimated variance147 ///148 ///The variance is calculated as \f$ \frac{1}{N}\sum_i149 ///(x_im)^2 \f$, where \f$ m \f$ is the mean.150 ///151 /// @return Estimation of variance152 ///145 /** 146 \brief The estimated variance 147 148 The variance is calculated as \f$ \frac{1}{N}\sum_i 149 (x_im)^2 \f$, where \f$ m \f$ is the mean. 150 151 \return Estimation of variance 152 */ 153 153 double variance(void) const; 154 154 
trunk/yat/statistics/AveragerPair.cc
r1000 r1122 51 51 double AveragerPair::ccc(void) const 52 52 { 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()))); 57 56 } 58 57 59 58 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()); 62 60 } 63 61 64 62 double AveragerPair::covariance(void) const 65 63 { 66 return ( n()>1) ? (xy_  x_.sum_x()*y_.mean()) / n(): 0;64 return (xy_  x_.sum_x()*y_.mean()) / n(); 67 65 } 68 66 
trunk/yat/statistics/AveragerPair.h
r1043 r1122 73 73 \f$ \frac{\sum_i (x_im_x)(y_im_y)}{\sum_i 74 74 (x_im_x)^2+\sum_i (y_im_y)^2 + n(m_xm_y)^2} \f$ 75 76 In case of a zero denominator  zero is returned.77 75 78 76 @return Concordence correlation coefficient. 
trunk/yat/statistics/AveragerPairWeighted.cc
r1043 r1122 27 27 #include "AveragerPair.h" 28 28 #include "Averager.h" 29 #include "yat/classifier/DataLookup1D.h"30 #include "yat/classifier/DataLookupWeighted1D.h"31 29 32 30 #include <cassert> … … 63 61 double AveragerPairWeighted::correlation(void) const 64 62 { 65 return ( x_.variance()>0 && y_.variance()>0 ? 66 covariance() / sqrt(x_.variance()*y_.variance()) : 0 ); 63 return covariance() / sqrt(x_.variance()*y_.variance()); 67 64 } 68 65 
trunk/yat/statistics/AveragerPairWeighted.h
r1088 r1122 37 37 namespace theplu{ 38 38 namespace yat{ 39 namespace classifier{40 class DataLookup1D;41 class DataLookupWeighted1D;42 }43 39 namespace statistics{ 44 40 /// 
trunk/yat/statistics/AveragerWeighted.cc
r1000 r1122 52 52 double AveragerWeighted::mean(void) const 53 53 { 54 return sum_w () ? sum_wx()/sum_w() : 0;54 return sum_wx()/sum_w(); 55 55 } 56 56
Note: See TracChangeset
for help on using the changeset viewer.