# Changeset 703 for trunk/yat/statistics

Ignore:
Timestamp:
Dec 18, 2006, 1:47:44 AM (17 years ago)
Message:

Location:
trunk/yat/statistics
Files:
22 edited

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

 r680 } void Averager::add(double d, u_long n) { n_  += n; x_  += n*d; xx_ += n*d*d; } void Averager::rescale(double a) { x_  *= a; xx_ *= a*a; } void Averager::reset(void) { n_=0; x_=xx_=0.0; } const Averager& Averager::operator=(const Averager& a) { n_  = a.n_; x_  = a.x_; xx_ = a.xx_; return *this; } const Averager& Averager::operator+=(const Averager& a) {
• ## trunk/yat/statistics/Averager.h

 r680 /// Adding \a n (default=1) number of data point(s) with value \a d. /// inline void add(double d, u_long n=1) { n_+=n; x_+=n*d; xx_+=n*d*d;} void add(double d, u_long n=1); /// /// /// Rescales the object, \f$\forall x_i \rightarrow a*x_i \f$, /// @brief Rescales the object /// /// \f$\forall x_i \rightarrow a*x_i \f$, /// \f$\forall x_i^2 \rightarrow a^2*x_i^2 \f$ /// inline void rescale(double a) { x_*=a; xx_*=a*a; } inline void rescale(double a); /// /// /// The standard deviation is defined as the square root of the /// variance. /// @brief The standard deviation is defined as the square root of /// the variance. /// /// @return The standard deviation, root of the variance(). /// /// The standard deviation is defined as the square root of the /// variance. /// @brief The standard deviation is defined as the square root of /// the variance. /// /// @return Standard deviation around \a m, root of the variance(m). /// /// @brief The variance with know mean /// /// The variance is calculated as /// \f$\frac{1}{n}\sum (x_i-m)^2 \f$. /// /// /// @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 /// @return Estimation of variance /// inline double variance(void) const /// /// Resets everything to zero /// inline void reset(void) { n_=0; x_=xx_=0.0;} /// /// The assignment operator /// inline const Averager& operator=(const Averager& a) { n_=a.n_; x_=a.x_; xx_=a.xx_; return *this; } /// @brief Reset everything to zero /// void reset(void); /// /// @brief The assignment operator /// const Averager& operator=(const Averager&); ///
• ## trunk/yat/statistics/AveragerPair.cc

 r683 namespace yat { namespace statistics { AveragerPair::AveragerPair(void) : x_(Averager()), y_(Averager()), xy_(0.0) { } AveragerPair::AveragerPair(const AveragerPair& a) : x_(a.x_averager()), y_(a.y_averager()), xy_(a.sum_xy()) { } void AveragerPair::add(const double x, const double y, const unsigned long n) { x_.add(x,n); y_.add(y,n); xy_ += n*x*y; } void AveragerPair::reset(void) { x_.reset(); y_.reset(); xy_=0.0; } const AveragerPair& AveragerPair::operator=(const AveragerPair& a) { x_=a.x_; y_=a.y_; xy_=a.xy_; return *this; } const AveragerPair& AveragerPair::operator+=(const AveragerPair& a) {
• ## trunk/yat/statistics/AveragerPair.h

 r680 /// /// Default constructor /// @brief The default constructor /// inline AveragerPair(void) : x_(Averager()), y_(Averager()), xy_(0.0) {} AveragerPair(void); /// /// Constructor taking sum of \a x , \a xx , \a y , \a yy , xy and /// /// Copy constructor /// The copy constructor /// inline AveragerPair(const AveragerPair& a) : x_(a.x_averager()), y_(a.y_averager()), xy_(a.sum_xy()) {} AveragerPair(const AveragerPair&); /// /// Adding \a n pairs of data points with value \a x and \a y. /// inline void add(const double x, const double y, const unsigned long n=1) { x_.add(x,n); y_.add(y,n), xy_ += n*x*y; } void add(const double x, const double y, const unsigned long n=1); /// /// /// Resets everything to zero /// @brief Reset everything to zero /// inline void reset(void) { x_.reset(); y_.reset(); xy_=0.0; } void reset(void); /// /// /// The assigment operator /// @brief The assigment operator /// inline const AveragerPair& operator=(const AveragerPair& a) { x_=a.x_; y_=a.y_; xy_=a.xy_; return *this; } const AveragerPair& operator=(const AveragerPair& a); ///
• ## trunk/yat/statistics/AveragerPairWeighted.cc

 r701 namespace yat { namespace statistics { AveragerPairWeighted::AveragerPairWeighted(void) : wxy_(0), w_(0) { } void  AveragerPairWeighted::add(const double x, const double y, } void AveragerPairWeighted::reset(void) { x_.reset(); y_.reset(); wxy_=0; w_=0; } }}} // of namespace statistics, yat, and theplu
• ## trunk/yat/statistics/AveragerPairWeighted.h

 r683 public: AveragerPairWeighted() : wxy_(0), w_(0) { } /// /// @brief The default constructor /// AveragerPairWeighted(void); /// /// /// reset everything to zero /// @brief Reset everything to zero /// inline void reset(void) { x_.reset(); y_.reset(); wxy_=0; w_=0; } void reset(void); ///
• ## trunk/yat/statistics/AveragerWeighted.cc

 r683 namespace statistics { AveragerWeighted AveragerWeighted::operator+=(const AveragerWeighted& a) AveragerWeighted::AveragerWeighted(void) : w_(Averager()), wx_(Averager()), wwx_(0), wxx_(0) { } AveragerWeighted::AveragerWeighted(const AveragerWeighted& a) : w_(Averager(a.sum_w(),a.sum_ww(),1)), wx_(Averager(a.sum_wx(),a.sum_wwxx(),1)), wwx_(a.sum_wwx()), wxx_(a.sum_wxx()) { } void AveragerWeighted::add(const double d, const double w) { if (!w) return; w_.add(w); wx_.add(w*d); wwx_+=w*w*d; wxx_+=w*d*d; } void AveragerWeighted::rescale(double a) { wx_.rescale(a); wwx_*=a; wxx_*=a*a; } void AveragerWeighted::reset(void) { wx_.reset(); w_.reset(); wwx_=0; wxx_=0; } const AveragerWeighted& AveragerWeighted::operator+=(const AveragerWeighted& a) { wx_+=a.wx(); w_+=a.w(); wwx_+=a.sum_wwx(); wxx_+=a.sum_wxx();
• ## trunk/yat/statistics/AveragerWeighted.h

 r699 /// /// Default constructor /// @brief The default constructor /// inline AveragerWeighted(void) : w_(Averager()), wx_(Averager()), wwx_(0), wxx_(0) {} /// /// Copy constructor /// inline AveragerWeighted(const AveragerWeighted& a) : w_(Averager(a.sum_w(),a.sum_ww(),1)), wx_(Averager(a.sum_wx(),a.sum_wwxx(),1)), wwx_(a.sum_wwx()), wxx_(a.sum_wxx()) {} /// /// adding a data point d, with weight w (default is 1) /// inline void add(const double d,const double w=1) { if(w==0) return; w_.add(w); wx_.add(w*d); wwx_+=w*w*d; wxx_+=w*d*d; } AveragerWeighted(void); /// /// @brief The copy constructor /// AveragerWeighted(const AveragerWeighted&); /// /// Adding a data point \a d, with weight \a w (default is 1) /// void  add(const double d,const double w=1); /// /// /// Calculating the weighted mean /// @brief Calculate the weighted mean /// /// @return \f$\frac{\sum w_ix_i}{\sum w_i} \f$ /// inline double mean(void) const { return sum_w() ? sum_wx()/sum_w() : 0; } inline double mean(void) const { return sum_w() ? sum_wx()/sum_w() : 0; } /// /// /// rescale object, i.e. each data point is rescaled /// \f$x = a * x \f$ /// inline void rescale(double a) { wx_.rescale(a); wwx_*=a; wxx_*=a*a; } /// /// resets everything to zero /// inline void reset(void) { wx_.reset(); w_.reset(); wwx_=0; wxx_=0; } /// /// The standard deviation is defined as the square root of the /// variance(). /// @brief Rescale object. /// /// Each data point is rescaled as \f$x = a * x \f$ /// void rescale(double a); /// /// @brief Reset everything to zero. /// void reset(void); /// /// @brief The standard deviation is defined as the square root of /// the variance(). /// /// @return The standard deviation, root of the variance(). /// /// Calculates standard deviation of the mean(). Variance from the /// @brief Calculates standard deviation of the mean(). /// /// Variance from the /// weights are here neglected. This is true when the weight is /// known before the measurement. In case this is not a good /// operator to add a AveragerWeighted /// AveragerWeighted operator+=(const AveragerWeighted&); const AveragerWeighted& operator+=(const AveragerWeighted&); Averager w_; double wxx_; inline Averager wx(void) const {return wx_;} inline Averager w(void) const {return w_;} inline Averager wx(void) const { return wx_; } inline Averager w(void) const { return w_; } };
• ## trunk/yat/statistics/Distance.cc

 r683 namespace statistics{ double Distance::operator()(const classifier::DataLookup1D& x, Distance::Distance(void) { } Distance::~Distance(void) { } double Distance::operator()(const classifier::DataLookup1D& x, const classifier::DataLookup1D& y) const {
• ## trunk/yat/statistics/Distance.h

 r683 public: Distance() { } /// /// @brief The default constructor /// Distance(void); virtual ~Distance() { } /// /// @brief The destructor /// virtual ~Distance(void); ///
• ## trunk/yat/statistics/Pearson.cc

 r683 Pearson::Pearson(bool b) : Score(b), r_(0), nof_samples_(0) { } Pearson::~Pearson(void) { }
• ## trunk/yat/statistics/Pearson.h

 r683 class Pearson : public Score { public: /// /// Default Constructor. /// @brief The default constructor. /// Pearson(bool absolute=true); /// /// Destructor /// @brief The destructor. /// virtual ~Pearson(void) {}; virtual ~Pearson(void);
• ## trunk/yat/statistics/PearsonDistance.cc

 r683 namespace statistics{ PearsonDistance::PearsonDistance(void) : Distance() { } PearsonDistance::~PearsonDistance(void) { } double PearsonDistance::operator()(const utility::vector& x, const utility::vector& y) const
• ## trunk/yat/statistics/PearsonDistance.h

 r683 public: PearsonDistance() : Distance() { } PearsonDistance(void); virtual ~PearsonDistance() { } virtual ~PearsonDistance(void); // Use all operator() from Distance except the ones that are // overloaded in this class. const utility::vector& wx, const utility::vector& wy) const; private: };
• ## trunk/yat/statistics/ROC.cc

 r683 ROC::ROC(bool b) : Score(b), area_(0.5), minimum_size_(10), nof_pos_(0) { } ROC::~ROC(void) { }
• ## trunk/yat/statistics/ROC.h

 r683 public: /// /// Default constructor /// @brief Default constructor /// ROC(bool absolute=true); /// /// Destructor /// @brief The destructor /// virtual ~ROC(void) {}; virtual ~ROC(void); /// Function taking \a value, \a target (+1 or -1) and vector
• ## trunk/yat/statistics/SNR.h

 r683 public: /// /// Default Constructor. /// @brief Default Constructor. /// SNR(bool absolute=true);
• ## trunk/yat/statistics/Score.cc

 r683 } Score::~Score(void) { } double Score::score(const classifier::Target& target, const classifier::DataLookup1D& value) { assert(target.size()==value.size()); utility::vector a; classifier::convert(value,a); return score(target,a); } double Score::score(const classifier::Target& target, const classifier::DataLookup1D& value, const classifier::DataLookup1D& weight) { utility::vector a; classifier::convert(value,a); utility::vector b; classifier::convert(weight,a); return score(target,a,b); } }}} // of namespace statistics, yat, and theplu
• ## trunk/yat/statistics/Score.h

 r683 public: /// ///   Constructor /// @brief Constructor /// Score(bool absolute=true) ; /// ///   Destructor /// @brief Destructor /// virtual ~Score(void) {}; virtual ~Score(void); /// /// Function changing mode of Score /// @brief Function changing mode of Score /// inline void absolute(bool absolute) {absolute_=absolute;} /// @param value vector of the values /// inline double score(const classifier::Target& target, const classifier::DataLookup1D& value) { assert(target.size()==value.size()); utility::vector a; classifier::convert(value,a); return score(target,a); } double score(const classifier::Target& target, const classifier::DataLookup1D& value); /// /// is wanted. /// inline double score(const classifier::Target& target, const classifier::DataLookup1D& value, const classifier::DataLookup1D& weight) { utility::vector a; classifier::convert(value,a); utility::vector b; classifier::convert(weight,a); return score(target,a,b); } double score(const classifier::Target& target, const classifier::DataLookup1D& value, const classifier::DataLookup1D& weight); protected:
• ## trunk/yat/statistics/tScore.h

 r683 public: /// /// Default Constructor. /// 2brief Default Constructor. /// tScore(bool absolute=true);
• ## trunk/yat/statistics/utility.cc

 r683 p+= gsl_ran_hypergeometric_pdf(i, n1, n2, t); return p; } double kurtosis(const utility::vector& v) { const gsl_vector* gvp=v.gsl_vector_p(); return gsl_stats_kurtosis(gvp->data,gvp->stride,gvp->size); } } double skewness(const utility::vector& v) { const gsl_vector* gvp=v.gsl_vector_p(); return gsl_stats_skew(gvp->data,gvp->stride,gvp->size); } }}} // of namespace statistics, yat, and theplu
• ## trunk/yat/statistics/utility.h

 r683 //forward declarations template inline double median(const std::vector& v, const bool sorted=false); double median(const std::vector& v, const bool sorted=false); template /// /// Computes the kurtosis of the data in a vector. The kurtosis /// measures how sharply peaked a distribution is, relative to its /// width. The kurtosis is normalized to zero for a gaussian /// distribution. /// @brief Computes the kurtosis of the data in a vector. /// inline double kurtosis(const utility::vector& v) { const gsl_vector* gvp=v.gsl_vector_p(); return gsl_stats_kurtosis(gvp->data,gvp->stride,gvp->size); } /// The kurtosis measures how sharply peaked a distribution is, /// relative to its width. The kurtosis is normalized to zero for a /// gaussian distribution. /// double kurtosis(const utility::vector&); /// /// Computes the skewness of the data in a vector. The skewness /// measures the asymmetry of the tails of a distribution. /// @brief Computes the skewness of the data in a vector. /// inline double skewness(const utility::vector& v) { const gsl_vector* gvp=v.gsl_vector_p(); return gsl_stats_skew(gvp->data,gvp->stride,gvp->size); } /// The skewness measures the asymmetry of the tails of a /// distribution. /// double skewness(const utility::vector&); }}} // of namespace statistics, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.