Changeset 196


Ignore:
Timestamp:
Oct 27, 2004, 7:45:04 PM (18 years ago)
Author:
Jari Häkkinen
Message:

Changed Statistics class to statisics namespace.
Fixed other minor issues.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ConsensusInputRanker.cc

    r152 r196  
    3131    }
    3232    // Sorting with respect to median rank
    33     theplu::cpptools::Statistics stat;
    3433    std::vector<std::pair<size_t,double> > median(data.rows());
    3534    for (size_t i=0; i<data.rows(); i++){
     
    3938     
    4039      median[i].first = i;
    41       median[i].second = stat.median(ranks);
     40      median[i].second = statistics::median(ranks);
    4241    }
    4342   
     
    7069   
    7170    // Sorting with respect to median rank
    72     theplu::cpptools::Statistics stat;
    7371    std::vector<std::pair<size_t,double> > median(data.rows());
    7472    for (size_t i=0; i<data.rows(); i++){
     
    7775        ranks[j]=input_rankers_[j].rank(i);
    7876      median[i].first = i;
    79       median[i].second = stat.median(ranks);
     77      median[i].second = statistics::median(ranks);
    8078    }
    8179   
  • trunk/src/Fisher.cc

    r187 r196  
    4545    // the matrix.
    4646    if (a_<b_ && a_<c_ && a_<d_)
    47       return Statistics().cdf_hypergeometric_P(a_,a_+b_,c_+d_,a_+c_);
     47      return statistics::cdf_hypergeometric_P(a_,a_+b_,c_+d_,a_+c_);
    4848    else if (b_<a_ && b_<c_ && b_<d_)
    49       return Statistics().cdf_hypergeometric_P(b_,a_+b_,c_+d_,b_+d_);
     49      return statistics::cdf_hypergeometric_P(b_,a_+b_,c_+d_,b_+d_);
    5050    else if (c_<a_ && c_<b_ && c_<d_)
    51       return Statistics().cdf_hypergeometric_P(c_,c_+d_,a_+b_,a_+c_);
     51      return statistics::cdf_hypergeometric_P(c_,c_+d_,a_+b_,a_+c_);
    5252    else
    53       return Statistics().cdf_hypergeometric_P(d_,c_+d_,a_+b_,b_+d_);
     53      return statistics::cdf_hypergeometric_P(d_,c_+d_,a_+b_,b_+d_);
    5454  }
    5555
  • trunk/src/Makefile.am

    r195 r196  
    1313  InputRanker.cc \
    1414  Kernel.cc kNNI.cc matrix.cc Merge.cc NNI.cc PCA.cc \
    15   PolynomialKernelFunction.cc random_singleton.cc
     15  PolynomialKernelFunction.cc random_singleton.cc \
    1616  RegressionLinear.cc ROC.cc Score.cc Statistics.cc \
    1717  SVD.cc SVM.cc tScore.cc vector.cc WeightedAverager.cc WeNNI.cc
  • trunk/src/RegressionLinear.cc

    r193 r196  
    99
    1010namespace theplu {
    11 namespace cpptools {
     11namespace statistics {
    1212
    1313 
     
    1717  }
    1818
    19   RegressionLinear::fit(gslapi::vector x_vec, gslapi::vector y_vec)
    20   {
    21     int tmp gsl_fit_linear(x, 1, y, 1, n, &k_, &m_,
    22                            &cov00_, &cov01_, &cov11_, &sumsq_)
    23 \
    2419
    25   }
    26 
    27   RegressionLinear::fit_weighted(gslapi::vector x, gslapi::vector y,
    28                            gslapi::vector w)
    29   {
    30 
    31   }
    32 
    33 
    34 }} // of namespace cpptools and namespace theplu
     20}} // of namespace statistics and namespace theplu
  • trunk/src/RegressionLinear.h

    r193 r196  
    4040    /// \f$.
    4141    ///
    42     inline void fit(const gslapi::vector& x, const gslapi::vector& y)
    43     {int tmp = gsl_fit_linear_vector(&x, &y, &m_, &k_,
    44                                      &cov00_, &cov01_, &cov11, &sumsq);} 
     42    inline int fit(const gslapi::vector& x, const gslapi::vector& y)
     43      { return gsl_fit_linear_vector(x.gsl_vector_pointer(),
     44                                     y.gsl_vector_pointer(), &m_, &k_,
     45                                     &cov00_, &cov01_, &cov11_, &sumsq_); }
    4546
    4647    ///
     
    5152    /// \f$ y_i \f$
    5253    ///
    53     void fit_weigted(gslapi::vector x, gslapi::vector y, gslapi::vector w);
    54     {int tmp = gsl_fit_wlinear_vector(&x, &w, &y, &m_, &k_,
    55                                       &cov00_, &cov01_, &cov11, &sumsq);} 
     54    inline int fit_weigted(gslapi::vector x, gslapi::vector y, gslapi::vector w)
     55      { return gsl_fit_wlinear_vector(x.gsl_vector_pointer(),
     56                                      w.gsl_vector_pointer(),
     57                                      y.gsl_vector_pointer(), &m_, &k_,
     58                                      &cov00_, &cov01_, &cov11_, &sumsq_); }
    5659         
    5760  private:
  • trunk/src/Statistics.cc

    r186 r196  
    1515
    1616namespace theplu {
    17 namespace cpptools { 
    18 
    19   Statistics::Statistics(void)
    20      
    21   {
    22   }
     17namespace statistics { 
    2318
    2419  double cdf_hypergeometric_P(u_int k, u_int n1, u_int n2, u_int t)
     
    3126
    3227
    33   double Statistics::median(std::vector<double>& vec)
     28  double median(std::vector<double>& vec)
    3429  {
    3530    return percentile(vec, 50.0);
    3631  }
    3732
    38   double Statistics::median(std::vector<size_t>& vec)
     33  double median(std::vector<size_t>& vec)
    3934  {
    4035    return percentile(vec, 50.0);
    4136  }
    4237
    43   double Statistics::percentile(std::vector<double>& vec, double percentile)
     38  double percentile(std::vector<double>& vec, double percentile)
    4439  {
    4540    if (percentile==100)
     
    5348  }
    5449
    55   double Statistics::percentile(std::vector<size_t>& vec, double percentile)
     50  double percentile(std::vector<size_t>& vec, double percentile)
    5651  {
    5752    if (percentile==100)
     
    6762
    6863
    69 }} // of namespace cpptools and namespace theplu
     64}} // of namespace statistics and namespace theplu
  • trunk/src/Statistics.h

    r186 r196  
    1212
    1313namespace theplu {
    14 namespace cpptools { 
    15 
    16   ///
    17   /// Class for basic statistics
    18   ///   
    19   class Statistics
    20   {
    21  
    22   public:
    23     ///
    24     /// Constructor
    25     ///
    26     Statistics();
     14// Jari, this should probably go somewhere else for doxygen to process.
     15///
     16/// Statistics functions should go into the statistics namespace
     17///
     18/// \brief Container for statistics functions
     19///
     20namespace statistics { 
    2721
    2822    ///
     
    8175    double percentile(std::vector<size_t>&, double i);
    8276
    83   private:
    84 
    85          
    86   };
    87 
    88 }} // of namespace cpptools and namespace theplu
     77}} // of namespace statistics and namespace theplu
    8978
    9079#endif
  • trunk/test/test_kernel.cc

    r164 r196  
    11// $Id$
    22
    3 
    4 #ifndef _THEP_CPPTOOLS_SVM_
    5 #define _THEP_CPPTOOLS_SVM_
    63
    74// C++ tools include
     
    1411// Standard includes
    1512////////////////////
     13#include <cmath>
    1614#include <fstream>
    1715#include <iostream>
     
    6563  return -1;
    6664}
    67 
    68 
    69 
    70 #endif
    71 
    72 
    73 
    74 
    75 
  • trunk/test/test_nni.cc

    r175 r196  
    11// $Id$
    22
     3#include <cmath>
    34#include <iostream>
    45#include <fstream>
  • trunk/test/test_roc.cc

    r156 r196  
    1111////////////////////
    1212#include <gsl/gsl_cdf.h>
     13#include <cmath>
    1314#include <fstream>
    1415#include <iostream>
  • trunk/test/test_statistics.cc

    r116 r196  
    1717
    1818  std::vector<double> data;
    19   theplu::cpptools::Statistics stat;
    2019  for (unsigned int i=0; i<10; i++)
    2120    data.push_back(static_cast<double>(i));
    22   double m=stat.median(data);
     21  double m=theplu::statistics::median(data);
    2322  if (m!=4.5)
    2423    return -1;
Note: See TracChangeset for help on using the changeset viewer.