Changeset 1003


Ignore:
Timestamp:
Jan 18, 2008, 11:13:13 PM (13 years ago)
Author:
Peter
Message:

adding class for Kolmogorov Smirnov test

Location:
trunk/yat
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/Makefile.am

    r1000 r1003  
    66# Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson
    77# Copyright (C) 2007 Jari Häkkinen, Peter Johansson
     8# Copyright (C) 2008 Peter Johansson
    89#
    910# This file is part of the yat library, http://trac.thep.lu.se/yat
     
    2930libstatistics_la_SOURCES = AUC.cc Averager.cc AveragerPair.cc \
    3031  AveragerWeighted.cc AveragerPairWeighted.cc \
    31   Fisher.cc FoldChange.cc Histogram.cc Pearson.cc \
     32  Fisher.cc FoldChange.cc Histogram.cc \
     33  KolmogorovSmirnov.cc Pearson.cc \
    3234  PearsonCorrelation.cc ROC.cc \
    3335  SAMScore.cc Score.cc SNRScore.cc tScore.cc tTest.cc \
     
    3941  AveragerWeighted.h AveragerPairWeighted.h \
    4042  euclidean_vector_distance.h Fisher.h \
    41   FoldChange.h Histogram.h Pearson.h PearsonCorrelation.h \
     43  FoldChange.h Histogram.h \
     44  KolmogorovSmirnov.h \
     45  Pearson.h PearsonCorrelation.h \
    4246  pearson_vector_distance.h ROC.h \
    4347  SAMScore.h Score.h SNRScore.h tScore.h tTest.h \
  • trunk/yat/utility/stl_utility.h

    r1000 r1003  
    3636
    3737#include <algorithm>
     38#include <functional>
    3839#include <ostream>
    3940#include <string>
     
    5657namespace yat {
    5758namespace utility {
     59
     60  /**
     61     Functor class taking absolute value
     62  */
     63  template<typename T>
     64  struct abs : std::unary_function<T, T>
     65  {
     66    /**
     67       \return absolute value
     68     */
     69    inline T operator()(T x) const
     70    { return std::abs(x); }
     71  };
     72
     73  /**
     74     See The C++ Standard Library - A Tutorial and Reference by
     75     Nicolai M. Josuttis
     76
     77     If f is a binary functor, both g and h are unary functors, and
     78     return type of g (and h) is convertible to F's argument type,
     79     then compose_f_gx_hy can be used to create a functor equivalent
     80     to \f$ f(g(x), h(y)) \f$
     81   */
     82  template<class F, class G, class H>
     83  class compose_f_gx_hy
     84  {
     85  public:
     86    /**
     87       \brief Constructor
     88     */
     89    compose_f_gx_hy(F f, G g, H h)
     90      : f_(f), g_(g), h_(h) {}
     91
     92    /**
     93       \brief Does the work
     94     */
     95    bool
     96    operator()(double x,
     97               double y) const
     98    {
     99      return f_(g_(x), h_(y));
     100    }
     101
     102  private:
     103    F f_;
     104    G g_;
     105    H h_;
     106  };
     107
     108  /**
     109     Convenient function to create a compose_f_gx_hy.
     110
     111     \see std::make_pair
     112  */
     113  template<class F, class G, class H>
     114  compose_f_gx_hy<F, G, H> make_compose_f_gx_hy(F f, G g, H h)
     115  {
     116    return compose_f_gx_hy<F,G,H>(f,g,h);
     117  } 
    58118
    59119  /**
Note: See TracChangeset for help on using the changeset viewer.