Changeset 295 for trunk/lib/statistics


Ignore:
Timestamp:
Apr 29, 2005, 11:15:58 AM (17 years ago)
Author:
Peter
Message:

file structure modifications. NOTE, this revision is not working, please wait for the next...

Location:
trunk/lib
Files:
3 added
34 moved

Legend:

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

    r294 r295  
    11// $Id$
    22
    3 #include "Averager.h"
     3#include <c++_tools/statistics/Averager.h>
     4#include <c++_tools/gslapi/vector.h>
    45
    56#include <sys/types.h>
    67#include <ostream>
    7 #include "vector.h"
    8 
    98
    109namespace theplu {
  • trunk/lib/statistics/Averager.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_averager_
    4 #define _theplu_cpptools_averager_
     3#ifndef _theplu_statistics_averager_
     4#define _theplu_statistics_averager_
    55
    66#include <cmath>
    7 #include "vector.h"
    87
    98namespace theplu{
     9namespace gslapi{
     10  class vector;
     11}
     12
    1013namespace statistics{
    1114  class ostream;
  • trunk/lib/statistics/AveragerPair.cc

    r294 r295  
    11// $Id$
    22
    3 #include "AveragerPair.h"
     3#include <c++_tools/statistics/AveragerPair.h>
     4#include <c++_tools/statistics/Averager.h>
    45
    5 #include "Averager.h"
    6 //#include <sys/types.h>
    7 //#include <ostream>
    8 //#include "vector.h"
    96#include <utility>
    107
  • trunk/lib/statistics/AveragerPair.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_averagerpair_
    4 #define _theplu_cpptools_averagerpair_
     3#ifndef _theplu_statistics_averagerpair_
     4#define _theplu_statistics__averagerpair_
     5
     6#include <c++_tools/statistics/Averager.h>
    57
    68#include <cmath>
    79#include <utility>
    810
    9 #include "Averager.h"
    1011
    1112namespace theplu{
  • trunk/lib/statistics/AveragerWeighted.cc

    r294 r295  
    11// $Id$
    22
    3 #include <sys/types.h>
     3#include <c++_tools/statistics/AveragerWeighted.h>
     4#include <c++_tools/statistics/Averager.h>
    45
    56#include <ostream>
    6 
    7 #include "Averager.h"
    8 #include "WeightedAverager.h"
     7#include <sys/types.h>
    98
    109namespace theplu {
     
    1211 
    1312
    14   WeightedAverager::WeightedAverager(void)
     13  AveragerWeighted::AveragerWeighted(void)
    1514    : w_(Averager()), wx_(Averager()), wwx_(0)
    1615  {
    1716  }
    1817
    19   WeightedAverager::WeightedAverager(const double d, const double w)
     18  AveragerWeighted::AveragerWeighted(const double d, const double w)
    2019    : w_(Averager(w,w*w,1)), wx_(Averager(w*d,w*w*d*d,1)), wwx_(w*w*d)
    2120  {
    2221  }
    2322
    24   WeightedAverager::WeightedAverager(const WeightedAverager& a)
     23  AveragerWeighted::AveragerWeighted(const AveragerWeighted& a)
    2524    : w_(Averager(a.sum_w(), a.sum_ww(),1)),
    2625      wx_(Averager(a.sum_wx(),a.sum_wwxx(),1)), wwx_(a.sum_wwx())
  • trunk/lib/statistics/AveragerWeighted.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_weighted_averager_
    4 #define _theplu_cpptools_weighted_averager_
     3#ifndef _theplu_statistics_averager_weighted_
     4#define _theplu_statistics_averager_weighted_
    55
    6 //#include <cmath>
    7 #include "Averager.h"
     6#include <c++_tools/statistics/Averager.h>
     7
     8#include <ostream>
    89
    910namespace theplu{
    1011namespace statistics{
     12
    1113  ///
    1214  /// Class to calulate simple (first and second moments) averages
     
    1517  /// @see Averager
    1618  ///
    17   class WeightedAverager
     19  class AveragerWeighted
    1820  {
    1921  public:
     
    2224    /// Default constructor
    2325    ///
    24     WeightedAverager(void);
     26    AveragerWeighted(void);
    2527
    2628    ///
     
    2830    /// weight (default = 1)
    2931    ///
    30     WeightedAverager(const double, const double=1);
     32    AveragerWeighted(const double, const double=1);
    3133
    3234    ///
    3335    /// Copy constructor
    3436    ///
    35     WeightedAverager(const WeightedAverager&);
     37    AveragerWeighted(const AveragerWeighted&);
    3638
    3739    ///
     
    117119
    118120    ///
    119     /// operator to add a WeightedAverager
     121    /// operator to add a AveragerWeighted
    120122    ///
    121     inline WeightedAverager operator+=(WeightedAverager& a)
     123    inline AveragerWeighted operator+=(AveragerWeighted& a)
    122124    { wx_+=a.wx(); w_+=a.w(); wwx_+=a.sum_wwx(); return *this; }
    123125   
     
    133135
    134136///
    135 /// The WeightedAverager output operator
     137/// The AveragerWeighted output operator
    136138///
    137 std::ostream& operator<<(std::ostream& s,const WeightedAverager&);
     139std::ostream& operator<<(std::ostream& s,const AveragerWeighted&);
    138140
    139141}} // of namespace statistics and namespace theplu
  • trunk/lib/statistics/Fisher.cc

    r294 r295  
    11// $Id$
    22
    3 #include "Fisher.h"
    4 
    5 #include "Score.h"
    6 #include "Statistics.h"
     3#include <c++_tools/statistics/Fisher.h>
     4#include <c++_tools/statistics/Score.h>
     5#include <c++_tools/statistics/Statistics.h>
    76
    87namespace theplu {
    9 namespace cpptools {
     8namespace statistics {
    109
    1110 
     
    2221  {
    2322    // If a column sum or a row sum is zero, the table is nonsense
    24     if (a*d==0 && c*b==0){
    25       std::cout << "Fisher: Table is not valid\n";
    26       exit (-1);
     23    if ((a==0 || d==0) && (c==0 || b==0)){
     24      std::cerr << "Warning: Fisher: Table is not valid\n";
     25      return 1.0;
    2726    }
    2827
    29     if (a*b*c*d){
    30       double ratio=a/b*d/c;
    31       if (absolute_ && ratio<1)
    32         return 1/ratio;
    33       else
    34         return ratio;
    35     }     
    36     else
    37       return 0.0;
     28    double ratio=(a*d)/(b*d);
     29    if (absolute_ && ratio<1)
     30      return 1/ratio;
     31    else
     32      return ratio;
    3833  }
    3934
     
    6661    else
    6762      train_set_ = train_set;
    68     a_=0;
    6963    a_=b_=c_=d_=0;
    7064    for (size_t i=0; i<train_set_.size(); i++)
     
    8175       
    8276    // If a column sum or a row sum is zero, the table is nonsense
    83     if (a_*d_==0 && c_*b_==0){
    84       std::cout << "Fisher: Table is not valid\n";
    85       exit (-1);
     77    if ((a_==0 || d_==0) && (c_==0 || b_==0)){
     78      std::cerr << "Warning: Fisher: Table is not valid\n";
     79      return 0;
    8680    }
    8781
     
    136130  }
    137131
    138 }} // of namespace cpptools and namespace theplu
     132}} // of namespace statistics and namespace theplu
  • trunk/lib/statistics/Fisher.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_fisher_
    4 #define _theplu_cpptools_fisher_
     3#ifndef _theplu_statistics_fisher_
     4#define _theplu_statistics_fisher_
    55
    6 // C++ tools include
    7 /////////////////////
    8 #include "Score.h"
    9 #include "vector.h"
    10 //#include <gsl/gsl_cdf.h>
     6#include <c++_tools/statistics/Score.h>
     7#include <c++_tools/gslapi/vector.h>
    118
    12 // Standard C++ includes
    13 ////////////////////////
    14 //#include <utility>
    15 //#include <vector>
    169
    1710namespace theplu {
    18 namespace cpptools { 
     11namespace statistics { 
    1912  ///
    2013  /// Class for Fisher's exact test.   
     
    6558   
    6659    ///
     60    /// Function calculating score from 2x2 table for which the
     61    /// elements are calculated as follows \n
     62    /// a: #data \f$ x=1 \f$ AND \f$ y=1 \f$ \n
     63    /// b: #data \f$ x=-1 \f$ AND \f$ y=1 \f$ \n
     64    /// c: #data \f$ x=1 \f$ AND \f$ y=-1 \f$ \n
     65    /// d: #data \f$ x=-1 \f$ AND \f$ y=1 \f$ \n
     66    ///
    6767    /// @return odds ratio. If absolute_ is true and odds ratio is
    6868    /// less than unity 1 divided by odds ratio is returned
    6969    ///
    70     double score(const gslapi::vector&, const gslapi::vector&
     70    double score(const gslapi::vector& x, const gslapi::vector& y
    7171                 const std::vector<size_t>& = std::vector<size_t>());
    7272
    7373    ///
    74     /// Weighted version of odds ratio. Each element in 2x2 table is
    75     /// calculated as \f$ \sum weight_i \f$, so when each weight is
     74    /// Weighted version of score. Each element in 2x2 table is
     75    /// calculated as \f$ \sum w_i \f$, so when each weight is
    7676    /// unitary the same table is created as in the unweighted version
    7777    /// @return odds ratio
    7878    ///
    79     double score(const gslapi::vector&, const gslapi::vector&
    80                  const gslapi::vector&,
     79    double score(const gslapi::vector& x, const gslapi::vector& y
     80                 const gslapi::vector& w,
    8181                 const std::vector<size_t>& = std::vector<size_t>());
    8282
    8383    ///
    84     /// @return odds ratio  \f$ ad/bc\f$ 
     84    /// \f$ \frac{ad}{bc} \f$
    8585    ///
    86     double score(const u_int, const u_int, const u_int, const u_int);
     86    /// @return odds ratio. If absolute_ is true and odds ratio is
     87    /// less than unity, 1 divided by odds ratio is returned
     88    ///
     89    double score(const u_int a, const u_int b,
     90                 const u_int c, const u_int d);
    8791   
    88     double oddsratio(const double, const double,
    89                      const double, const double) const;
    9092
    9193         
     
    98100    u_int d_;
    99101
     102    double oddsratio(const double a, const double b,
     103                     const double c, const double d) const;
    100104
    101105  };
    102106
    103 }} // of namespace cpptools and namespace theplu
     107}} // of namespace statistics and namespace theplu
    104108
    105109#endif
  • trunk/lib/statistics/Histogram.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_histogram_
    4 #define _theplu_cpptools_histogram_
     3#ifndef _theplu_statistics_histogram_
     4#define _theplu_statistics_histogram_
     5
     6#include <c++_tools/statistics/AveragerWeighted.h>
    57
    68#include <string>
    79#include <vector>
    810
    9 #include "WeightedAverager.h"
    10 
    1111
    1212namespace theplu {
    13 namespace cpptools {
     13namespace statistics {
    1414
    1515  ///
     
    5858
    5959    ///
    60     /// Gives access to the WeightedAverager object that keeps track of
     60    /// Gives access to the AveragerWeighted object that keeps track of
    6161    /// average of all events presented to the histogram.
    6262    ///
    6363    /// @short Average of all events presented to the histogram.
    6464    ///
    65     /// @return A const reference to an WeightedAverager object.
     65    /// @return A const reference to an AveragerWeighted object.
    6666    ///
    67     inline const statistics::WeightedAverager& averager_all(void) const
     67    inline const statistics::AveragerWeighted& averager_all(void) const
    6868      { return sum_all_; }
    6969
    7070    ///
    71     /// Gives access to the WeightedAverager object that keeps track of
     71    /// Gives access to the AveragerWeighted object that keeps track of
    7272    /// average of events that fits within the histogram lower and
    7373    /// upper limits. This function is equivalent to averager().
     
    7575    /// @short Average of events fitting within histogram.
    7676    ///
    77     /// @return A const reference to an WeightedAverager object.
     77    /// @return A const reference to an AveragerWeighted object.
    7878    ///
    79     inline const statistics::WeightedAverager& averager_histogram(void) const
     79    inline const statistics::AveragerWeighted& averager_histogram(void) const
    8080      { return sum_histogram_; }
    8181
     
    144144    double xmax_;
    145145    double xmin_;
    146     statistics::WeightedAverager sum_all_;      // average of all data
    147     statistics::WeightedAverager sum_histogram_;// average of data in histogram
     146    statistics::AveragerWeighted sum_all_;      // average of all data
     147    statistics::AveragerWeighted sum_histogram_;// average of data in histogram
    148148  };
    149149
     
    153153std::ostream& operator<<(std::ostream& s,const Histogram&);
    154154
    155 }} // of namespace cpptools and namespace theplu
     155}} // of namespace statistics and namespace theplu
    156156
    157157#endif
  • trunk/lib/statistics/Kernel.cc

    r294 r295  
    11// $Id$
    22
    3 #include "RegressionKernel.h"
     3#include <c++_tools/statistics/Kernel.h>
    44
    55namespace theplu{
    66namespace statistics{
    77
    8   RegressionKernel::RegressionKernel(void)
     8  Kernel::Kernel(void)
    99  {
    1010  }
  • trunk/lib/statistics/Kernel.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_statistics_regression_kernel_
    4 #define _theplu_statistics_regression_kernel_
     3#ifndef _theplu_statistics_kernel_
     4#define _theplu_statistics_kernel_
    55
    66namespace theplu {
     
    1111  ///
    1212
    13   class RegressionKernel
     13  class Kernel
    1414  {
    1515   
     
    1818    /// Constructor
    1919    ///
    20     RegressionKernel();
     20    Kernel();
    2121
    2222    ///
  • trunk/lib/statistics/KernelBox.cc

    r294 r295  
    11// $Id$
    22
    3 #include "RegressionKernelBox.h"
    4 
    5 #include "RegressionKernel.h"
     3#include <c++_tools/statistics/KernelBox.h>
     4#include <c++_tools/statistics/Kernel.h>
    65
    76namespace theplu {
    87namespace statistics {
    98
    10   RegressionKernelBox::RegressionKernelBox(void)
    11     : RegressionKernel()
     9  KernelBox::KernelBox(void)
     10    : Kernel()
    1211  {
    1312  }
    1413
    15   double RegressionKernelBox::weight(const double u) const
     14  double KernelBox::weight(const double u) const
    1615  {
    1716    if (u>1 || u<-1)
  • trunk/lib/statistics/KernelTriCube.cc

    r294 r295  
    11// $Id$
    22
    3 #include "RegressionKernelTriCube.h"
    4 #include "RegressionKernel.h"
     3#include <c++_tools/statistics/KernelTriCube.h>
     4#include <c++_tools/statistics/Kernel.h>
    55
    66#include <cmath>
     
    99namespace statistics {
    1010
    11   RegressionKernelTriCube::RegressionKernelTriCube(void)
    12     : RegressionKernel()
     11  KernelTriCube::KernelTriCube(void)
     12    : Kernel()
    1313  {
    1414  }
    1515
    16   double RegressionKernelTriCube::weight(const double x) const
     16  double KernelTriCube::weight(const double x) const
    1717  {
    1818    if (x>1 || x<-1)
  • trunk/lib/statistics/KernelTriCube.h

    r294 r295  
    22
    33
    4 #ifndef _theplu_statistics_regression_kernel_tricube_
    5 #define _theplu_statistics_regression_kernel_tricube_
     4#ifndef _theplu_statistics_kernel_tricube_
     5#define _theplu_statistics_kernel_tricube_
    66
    7 #include "RegressionKernel.h"
     7#include <c++_tools/statistics/Kernel.h>
     8
    89
    910namespace theplu {
     
    1415  ///
    1516
    16   class RegressionKernelTriCube : public RegressionKernel
     17  class KernelTriCube : public Kernel
    1718  {
    1819   
     
    2122    /// Constructor
    2223    ///
    23     RegressionKernelTriCube() ;
     24    KernelTriCube() ;
    2425
    2526    ///
  • trunk/lib/statistics/Pearson.cc

    r294 r295  
    22
    33
    4 #include "Pearson.h"
     4#include <c++_tools/statistics/Pearson.h>
    55
    6 // System includes
     6#include <c++_tools/statistics/AveragerPair.h>
     7#include <c++_tools/gslapi/vector.h>
     8
    79#include <cmath>
    810#include <gsl/gsl_cdf.h>
    911
    10 // Thep C++ Tools
    11 #include "AveragerPair.h"
    12 #include "vector.h"
    13 
    1412
    1513namespace theplu {
    16 namespace cpptools { 
     14namespace statistics { 
    1715
    1816  Pearson::Pearson(bool b)
    19     : Score(b), r_(0), nof_samples_(0), weighted_(true)
     17    : Score(b), r_(0), nof_samples_(0)
    2018  {
    2119  }
    2220
    23   void centralize (vector& x, const vector& w)
     21  void Pearson::centralize(gslapi::vector& x, const gslapi::vector& w)
    2422  {
    2523    double m = (x*w)/w.sum();
     
    2826  }
    2927
    30   double Pearson::p_value() const;
     28  double Pearson::p_value() const
    3129  {
    3230    if(weighted_)
    3331      return 1;
    3432    else if(nof_samples_<3){
    35       std::cerr << "Warning: Only " << nof_samples_ << "samples. " <<
     33      std::cerr << "Warning: Only " << nof_samples_ << "samples. "
    3634                << "Need at lest 3.\n";
    3735      return 1;
    3836    }
    3937    else{
    40       t = sqrt(nof_samples_ - 2)*abs(r_) /sqrt(1-r_*r_);
    41       p = 2*gsl_cdf_tdist_Q (t, nof_samples_ -2 );
    42       return p;
     38      double t = sqrt(nof_samples_ - 2)*fabs(r_) /sqrt(1-r_*r_);
     39      return 2*gsl_cdf_tdist_Q (t, nof_samples_ -2 );
    4340    }
    4441  }
    4542
    4643  double Pearson::score(const gslapi::vector& vec1, const gslapi::vector& vec2,
    47                         const std::vector<size_t>& = std::vector<size_t>());
     44                        const std::vector<size_t>& train_set)
    4845  {
    4946    weighted_=false;
     47    AveragerPair ap;
    5048    if (!train_set.size()){
    51       AveragerPair x(vec1,vec2);
     49      ap = AveragerPair(vec1.sum(),vec1*vec1,vec2.sum(),vec2*vec2,
     50                        vec1*vec2,vec1.size());
    5251      nof_samples_ = vec1.size();
    5352    }
    5453    else{
    55       Averager a();
    5654      for (size_t i=0; i<train_set.size(); i++){
    57         a.add(vec1(train_set[i]), vec2(train_set[i]));
     55        ap.add(vec1(train_set[i]), vec2(train_set[i]));
    5856      }
    5957      nof_samples_ = train_set.size();
    6058    }
    61     r_ = a.correlation();
    62     weighted_=false;
    63     if (r<0 && absolute_)
     59    r_ = ap.correlation();
     60    if (r_<0 && absolute_)
    6461      r_=-r_;
    6562     
     
    6865   
    6966  double Pearson::score(const gslapi::vector& vec1, const gslapi::vector& vec2,
    70                         const gslapi::vector& weight,
     67                        const gslapi::vector& w1, const gslapi::vector& w2,
    7168                        const std::vector<size_t>& train_set =
    72                         std::vector<size_t>());
     69                        std::vector<size_t>())
    7370  {
    7471    weighted_=true;
     72    gslapi::vector x;
     73    gslapi::vector y;
     74    gslapi::vector wx;
     75    gslapi::vector wy;
    7576    if (!train_set.size()){
    76       gslapi::vector x = vec1;
    77       gslapi::vector y = vec2;
    78       gslapi::vector w = weights;
     77      x = vec1;
     78      y = vec2;
     79      wx = w1;
     80      wy = w2;
    7981      nof_samples_ = vec1.size();
    8082    }
    8183    else{
    8284      nof_samples_ = train_set.size();
    83       gslapi::vector x(nof_samples_);
    84       gslapi::vector y(nof_samples_);
    85       gslapi::vector w(nof_samples_);
     85      x = gslapi::vector(nof_samples_);
     86      y = gslapi::vector(nof_samples_);
     87      wx = gslapi::vector(nof_samples_);
     88      wy = gslapi::vector(nof_samples_);
    8689      for (size_t i=0; i<train_set.size(); i++){
    8790        x(i)=vec1(train_set[i]);
    8891        y(i)=vec2(train_set[i]);
    89         w(i)=weight(train_set[i]);
     92        wx(i)=w1(train_set[i]);
     93        wy(i)=w2(train_set[i]);
    9094      }
    9195    }
    9296
    93     centralize(x,w);
    94     centralize(y,w);
     97    centralize(x,wx);
     98    centralize(y,wy);
    9599
    96     r_ = ( (x.mul_elements(w)*y) /
    97            sqrt( (x.mul_elements(w)*x)*(y.mul_elements(w)*y)) );
     100    x.mul(wx);
     101    y.mul(wy);
     102
     103    r_ = ( (x*y) / sqrt( (x*x)*(y*y)) );
    98104    weighted_=true;
    99105
    100     if (r<0 && absolute_)
     106    if (r_<0 && absolute_)
    101107      r_=-r_;
    102108     
    103109    return r_;
    104   }
    105 
    106   double Pearson::score(const gslapi::vector& vec1, const gslapi::vector& vec2,
    107                         const gslapi::vector& w1, const gslapi::vector& w2,
    108                         const std::vector<size_t>& train_set =
    109                         std::vector<size_t>());
    110   {
    111     weighted_=true;
    112     return = score(vec1, vec2, w1.mul_elements(w2),train_set);
    113110  }
    114111
    115 }} // of namespace cpptools and namespace theplu
     112}} // of namespace statistics and namespace theplu
  • trunk/lib/statistics/Pearson.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_pearson_
    4 #define _theplu_cpptools_pearson_
     3#ifndef _theplu_statistics_pearson_
     4#define _theplu_statistics_pearson_
    55
    6 // C++ tools include
    7 /////////////////////
    8 #include "Score.h"
    9 #include "vector.h"
    10 //#include <gsl/gsl_cdf.h>
    11 
    12 // Standard C++ includes
    13 ////////////////////////
    14 //#include <utility>
    15 //#include <vector>
    16 
     6#include <c++_tools/statistics/Score.h>
    177
    188//Peter, should add a function to get the sign of the correlation
    199namespace theplu {
    20 namespace cpptools { 
     10  class gslapi::vector;
     11
     12namespace statistics { 
     13
    2114  ///
    2215  /// Class for calculating Pearson correlation.
     
    4841
    4942    ///
    50     /// \f$ \frac{\vert \sum_iw_i(x_i-\bar{x})(y_i-\bar{y})\vert }
    51     /// {\sqrt{\sum_iw_i(x_i-\bar{x})^2\sum_iw_i(x_i-\bar{x})^2}}\f$,
     43    /// \f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert }
     44    /// {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}}\f$,
    5245    /// where \f$m_x = \frac{\sum w_ix_i}{\sum w_i}\f$ and \f$m_x =
    5346    /// \frac{\sum w_ix_i}{\sum w_i}\f$. This expression is chosen to
     
    5649    /// correlation.
    5750    ///
    58     double score(const gslapi::vector& x, const gslapi::vector& y, 
    59                  const gslapi::vector& w,
    60                  const std::vector<size_t>& = std::vector<size_t>());
     51    inline double score(const gslapi::vector& x, const gslapi::vector& y,
     52                        const gslapi::vector& w,
     53                        const std::vector<size_t>& train_set =
     54                        std::vector<size_t>())
     55    { return score(x,y,w,w,train_set); }
    6156
    6257    ///
     
    7267    double score(const gslapi::vector& x, const gslapi::vector& y, 
    7368                 const gslapi::vector& wx, const gslapi::vector& wy,
    74                  const std::vector<size_t>& = std::vector<size_t>());
     69                 const std::vector<size_t>&);
    7570   
    7671    ///
     
    8883
    8984
    90     void centralize(vector, const vector);
     85    void centralize(gslapi::vector&, const gslapi::vector&);
    9186  };
    9287
    93 }} // of namespace cpptools and namespace theplu
     88}} // of namespace statistics and namespace theplu
    9489
    9590#endif
  • trunk/lib/statistics/ROC.cc

    r294 r295  
    11// $Id$
    22
    3 #include "ROC.h"
     3#include <c++_tools/statistics/ROC.h>
    44
    5 // System includes
     5#include <c++_tools/utility/stl_utility.h>
     6#include <c++_tools/gslapi/vector.h>
     7
     8#include <gsl/gsl_cdf.h>
     9
    610#include <cmath>
    7 #include <gsl/gsl_cdf.h>
    811#include <iostream>
    912#include <utility>
    1013#include <vector>
    1114
    12 // Thep C++ Tools
    13 #include "stl_utility.h"
    14 #include "vector.h"
    1515
    1616namespace theplu {
    17 namespace cpptools { 
     17namespace statistics { 
    1818
    1919  ROC::ROC(bool b)
     
    151151    }
    152152    std::sort(value_.begin(),value_.end(),
    153          pair_value_compare<double, double>());
     153         cpptools::pair_value_compare<double, double>());
    154154  }
    155155
  • trunk/lib/statistics/ROC.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_roc_
    4 #define _theplu_cpptools_roc_
     3#ifndef _theplu_statistics_roc_
     4#define _theplu_statistics_roc_
    55
    6 // C++ tools include
    7 /////////////////////
    8 #include "Score.h"
    9 #include "vector.h"
     6#include <c++_tools/gslapi/vector.h>
     7#include <c++_tools/statistics/Score.h>
    108
    11 // Standard C++ includes
    12 ////////////////////////
    139#include <utility>
    1410#include <vector>
    1511
    1612namespace theplu {
    17 namespace cpptools { 
     13namespace statistics { 
    1814  ///
    1915  /// Class for ROC (Reciever Operating Characteristic).
     
    9490    /// data.
    9591    std::vector<std::pair<double, double> > value_;
     92   
     93    /// Implemented as in MatLab 13.1
     94    double ROC::get_p_approx(const double) const;
    9695
    97    
    98     ///
    99     ///
    10096    /// Implemented as in MatLab 13.1
    101     /// @return the p-value
    102     ///
    103     double ROC::get_p_approx(const double) const;
    104    
    105     ///
    106     /// @return the p-value
    107     ///
    10897    double ROC::get_p_exact(const double, const double,
    10998                            const double) const;
    110  
    111     ///
     99
    112100    /// sorting value_, should always be done when changing train_set_
    113     ///
    114101    void ROC::sort();
    115102       
     
    124111
    125112
    126 }} // of namespace cpptools and namespace theplu
     113}} // of namespace statistics and namespace theplu
    127114
    128115#endif
  • trunk/lib/statistics/Regression.cc

    r294 r295  
    11// $Id$
    22
    3 #include "Regression.h"
     3#include <c++_tools/statistics/Regression.h>
    44
    55namespace theplu {
  • trunk/lib/statistics/Regression.h

    r294 r295  
    44#define _theplu_statistics_regression_
    55
    6 #include "vector.h"
    7 
     6#include <ostream>
    87
    98namespace theplu {
     9namespace gslapi {
     10  class vector;
     11}
     12
    1013namespace statistics { 
    1114
     
    4649                    const gslapi::vector& w)=0;
    4750    ///
    48     ///
     51    /// function predicting in one point
    4952    ///
    5053    virtual void predict(const double x, double& y, double& y_err,
     
    6164             
    6265  protected:
     66    ///
     67    /// x for predicted point
     68    ///
    6369    double x_;
     70    ///
     71    /// y for predicted point
     72    ///
    6473    double y_;
     74    ///
     75    /// estimated error of predicted point (in y).
     76    ///
    6577    double y_err_;
    6678  };
  • trunk/lib/statistics/RegressionLinear.cc

    r294 r295  
    11// $Id$
    22
    3 // Header
    4 #include "RegressionLinear.h"
     3#include <c++_tools/statistics/RegressionLinear.h>
    54
    6 // C++_tools
    7 #include "AveragerPair.h"
    8 #include "Regression.h"
    9 #include "vector.h"
     5#include <c++_tools/statistics/AveragerPair.h>
     6#include <c++_tools/statistics/Regression.h>
     7#include <c++_tools/gslapi/vector.h>
    108
    119#include <gsl/gsl_fit.h>
  • trunk/lib/statistics/RegressionLinear.h

    r294 r295  
    44#define _theplu_statistics_regression_linear_
    55
    6 // C++ tools include
    7 /////////////////////
    8 #include "Regression.h"
    9 #include "vector.h"
     6#include <c++_tools/statistics/Regression.h>
     7#include <c++_tools/gslapi/vector.h>
    108
    11 // Standard C++ includes
    12 ////////////////////////
    139#include <cmath>
    1410
  • trunk/lib/statistics/RegressionLocal.cc

    r294 r295  
    11// $Id$
    22
    3 #include "RegressionLocal.h"
     3#include <c++_tools/statistics/RegressionLocal.h>
    44
    5 #include "Regression.h"
    6 #include "RegressionKernel.h"
    7 #include "RegressionLinear.h"
    8 #include "vector.h"
     5#include <c++_tools/gslapi/vector.h>
     6#include <c++_tools/statistics/Kernel.h>
     7#include <c++_tools/statistics/Regression.h>
    98
    10 #include "algorithm"
     9//#include <algorithm>
    1110
    1211namespace theplu {
    1312namespace statistics {
    1413
    15   RegressionLocal::RegressionLocal(Regression& r,
    16                                    RegressionKernel& k)
     14  RegressionLocal::RegressionLocal(Regression& r, Kernel& k)
    1715    : kernel_(&k), regressor_(&r)
    1816  {
  • trunk/lib/statistics/RegressionLocal.h

    r294 r295  
    44#define _theplu_statistics_regression_local_
    55
    6 // C++ tools include
    7 /////////////////////
    8 #include "Regression.h"
    9 #include "RegressionKernel.h"
    10 #include "vector.h"
     6#include <c++_tools/statistics/RegressionLocal.h>
    117
    12 // Standard C++ includes
    13 ////////////////////////
     8#include <c++_tools/statistics/Kernel.h>
     9#include <c++_tools/statistics/Regression.h>
     10#include <c++_tools/gslapi/vector.h>
    1411
    1512
     
    4643    /// type of \a kernel.
    4744    ///
    48     RegressionLocal(Regression& regressor, RegressionKernel& kernel);
     45    RegressionLocal(Regression& regressor, Kernel& kernel);
    4946
    5047    ///
     
    9794  private:
    9895    std::vector<std::pair<double, double> > data_;
    99     RegressionKernel* kernel_;
     96    Kernel* kernel_;
    10097    Regression* regressor_;
    10198    std::vector<double> x_;
  • trunk/lib/statistics/RegressionNaive.cc

    r294 r295  
    22
    33
    4 #include "RegressionNaive.h"
     4#include <c++_tools/statistics/RegressionNaive.h>
    55
    6 #include "Averager.h"
    7 #include "Regression.h"
    8 #include "vector.h"
    9 #include "WeightedAverager.h"
     6#include <c++_tools/statistics/Averager.h>
     7#include <c++_tools/statistics/AveragerWeighted.h>
     8#include <c++_tools/statistics/Regression.h>
     9#include <c++_tools/gslapi/vector.h>
    1010
    1111#include <iostream>
     
    3535                            const gslapi::vector& w)
    3636  {
    37     WeightedAverager a;
     37    AveragerWeighted a;
    3838    for (size_t i=0; i<y.size(); i++)
    3939      a.add(y(i), w(i));
  • trunk/lib/statistics/RegressionNaive.h

    r294 r295  
    44#define _theplu_statistics_regression_naive_
    55
    6 // C++ tools include
    7 /////////////////////
    8 #include "Averager.h"
    9 #include "Regression.h"
    10 #include "vector.h"
    11 #include "WeightedAverager.h"
    12 // Standard C++ includes
    13 ////////////////////////
    14 //#include <gsl/gsl_fit.h>
     6#include <c++_tools/statistics/Regression.h>
     7
     8#include <c++_tools/gslapi/vector.h>
     9#include <c++_tools/statistics/Averager.h>
     10#include <c++_tools/statistics/AveragerWeighted.h>
     11#include <c++_tools/statistics/RegressionNaive.h>
     12
    1513#include <iostream>
    1614#include <utility>
  • trunk/lib/statistics/Score.cc

    r294 r295  
    11// $Id$
    22
    3 #include "Score.h"
     3#include <c++_tools/statistics/Score.h>
    44
    55namespace theplu {
    6 namespace cpptools { 
     6namespace statistics { 
    77
    88  Score::Score(bool absolute)
  • trunk/lib/statistics/Score.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_score_
    4 #define _theplu_cpptools_score_
     3#ifndef _theplu_statistics_score_
     4#define _theplu_statistics_score_
    55
    6 #include "vector.h"
     6#include <c++_tools/gslapi/vector.h>
    77
    88namespace theplu {
    9 namespace cpptools {
     9namespace statistics {
    1010
    1111  ///
     
    3131    inline void absolute(bool absolute) {absolute_=absolute;}
    3232
     33    ///
     34    /// @return statistica.
     35    ///
    3336    virtual double
    3437    score(const gslapi::vector&,
     
    3639          const std::vector<size_t>& = std::vector<size_t>()) = 0;
    3740 
     41    ///
     42    /// @return statistica (weighted version)
     43    ///
    3844    virtual double
    3945    score(const gslapi::vector&,
     
    4248          const std::vector<size_t>& = std::vector<size_t>()) = 0;
    4349
     50    ///
     51    /// @return the ///one-sided p-value( if absolute true is used
     52    /// this is equivalent to the two-sided p-value.)
     53    ///
    4454    virtual double p_value(void) const = 0;
    4555 
     
    5666  }; // class Score
    5767
    58 }} // of namespace cpptools and namespace theplu
     68}} // of namespace statistics and namespace theplu
    5969
    6070#endif
  • trunk/lib/statistics/tScore.h

    r294 r295  
    11// $Id$
    22
    3 #ifndef _theplu_cpptools_t_score_
    4 #define _theplu_cpptools_t_score_
     3#ifndef _theplu_statistics_t_score_
     4#define _theplu_statistics_t_score_
    55
    66// C++ tools include
    77/////////////////////
    8 #include "Score.h"
    9 #include "vector.h"
     8#include <c++_tools/statistics/Score.h>
     9#include <c++_tools/gslapi/vector.h>
     10
    1011#include <gsl/gsl_cdf.h>
    1112
    12 // Standard C++ includes
    13 ////////////////////////
    14 //#include <utility>
    15 //#include <vector>
    1613
    1714namespace theplu {
    18 namespace cpptools { 
     15namespace statistics { 
    1916  ///
    2017  /// Class for Fisher's t-test.
     
    7572  };
    7673
    77 }} // of namespace cpptools and namespace theplu
     74}} // of namespace statistics and namespace theplu
    7875
    7976#endif
Note: See TracChangeset for help on using the changeset viewer.