Changeset 3023


Ignore:
Timestamp:
Apr 6, 2013, 4:35:36 AM (10 years ago)
Author:
Peter
Message:

closes #754. ROC::area() is now const

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r3018 r3023  
    88  - PearsonCorrelation::one_sided_p(void) is now deprecated (ticket #689)
    99  - ROC::p_value_one_sided(void is now deprecated (ticket #689)
     10  - ROC::area(void) is now declared const (ticket #754)
    1011
    1112  A complete list of closed tickets can be found here [[br]]
  • trunk/yat/statistics/ROC.cc

    r3006 r3023  
    6666
    6767
    68   double ROC::area(void)
     68  double ROC::area(void) const
    6969  {
    7070    if (std::isnan(area_)){
     
    194194  double ROC::p_left() const
    195195  {
    196     double area(area_);
    197     if (std::isnan(area)){
    198       AUC auc(false);
    199       area = auc.score(multimap_);
    200     }
    201     if (std::isnan(area))
     196    if (std::isnan(area()))
    202197      return std::numeric_limits<double>::quiet_NaN();
    203198    if (use_exact_method())
    204       return p_exact_left(area);
    205     return get_p_approx(1-area);
     199      return p_exact_left(area());
     200    return get_p_approx(1-area());
    206201  }
    207202
     
    209204  double ROC::p_right() const
    210205  {
    211     double area(area_);
    212     if (std::isnan(area)){
    213       AUC auc(false);
    214       area = auc.score(multimap_);
    215     }
    216     if (std::isnan(area))
     206    if (std::isnan(area()))
    217207      return std::numeric_limits<double>::quiet_NaN();
    218208    if (use_exact_method())
    219       return p_exact_right(area);
    220     return get_p_approx(area);
     209      return p_exact_right(area());
     210    return get_p_approx(area());
    221211  }
    222212
     
    224214  double ROC::p_value() const
    225215  {
    226     double area(area_);
    227     if (std::isnan(area)){
    228       AUC auc(false);
    229       area = auc.score(multimap_);
    230     }
    231     if (std::isnan(area))
     216    if (std::isnan(area()))
    232217      return std::numeric_limits<double>::quiet_NaN();
    233218    if (use_exact_method()) {
    234219      double p = 0;
    235       double abs_area = std::max(area, 1-area);
     220      double abs_area = std::max(area(), 1-area());
    236221      p = p_exact_right(abs_area);
    237222      if (has_ties_) {
     
    243228      return std::min(p, 1.0);
    244229    }
    245     return 2*get_p_approx(area);
     230    return 2*get_p_approx(area());
    246231  }
    247232
  • trunk/yat/statistics/ROC.h

    r3007 r3023  
    8181       @return Area under curve.
    8282    */
    83     double area(void);
     83    double area(void) const;
    8484
    8585    /**
     
    313313    bool use_exact_method(void) const;
    314314
    315     double area_;
     315    mutable double area_;
    316316    bool has_ties_;
    317317    unsigned int minimum_size_;
  • trunk/yat/statistics/tTest.cc

    r2992 r3023  
    3535namespace theplu {
    3636namespace yat {
    37 namespace statistics { 
     37namespace statistics {
    3838
    39   tTest::tTest(void) 
     39  tTest::tTest(void)
    4040    : updated_(false)
    4141  {
    4242  }
    4343
    44  
     44
    4545  void tTest::add(double x, bool target, double w)
    4646  {
     
    5454  }
    5555
    56  
     56
    5757  void tTest::reset(void)
    5858  {
     
    7676
    7777
    78   double tTest::p_value(void) const
     78  double tTest::p_left(void) const
    7979  {
    80     double p=2*p_value_one_sided();
    81     return std::min(p,2-p);
     80    assert(0 && "not implemented yet");
    8281  }
    8382
    8483
    85   double tTest::p_value_one_sided(void) const
     84  double tTest::p_right(void) const
    8685  {
    8786    double t=t_;
     
    9695  }
    9796
     97
     98  double tTest::p_value(void) const
     99  {
     100    double p=2*p_right();
     101    return std::min(p,2-p);
     102  }
     103
     104
     105  double tTest::p_value_one_sided(void) const
     106  {
     107    return p_right();
     108  }
     109
    98110}}} // of namespace statistics, yat, and theplu
  • trunk/yat/statistics/tTest.h

    r2992 r3023  
    11#ifndef _theplu_yat_statistics_ttest_
    2 #define _theplu_yat_statistics_ttest_ 
     2#define _theplu_yat_statistics_ttest_
    33
    44// $Id$
     
    2626
    2727#include "AveragerWeighted.h"
     28#include "yat/utility/deprecate.h"
    2829
    2930#include <gsl/gsl_cdf.h>
     
    3132namespace theplu {
    3233namespace yat {
    33 namespace statistics { 
     34namespace statistics {
    3435
    3536  ///
    3637  /// @brief Class for Student's t-test.
    37   ///   
     38  ///
    3839  /// See <a href="http://en.wikipedia.org/wiki/Student's_t-test">
    3940  /// http://en.wikipedia.org/wiki/Student's_t-test</a> for more
    4041  /// details on the t-test.
    41   /// 
     42  ///
    4243  class tTest
    4344  {
    44  
     45
    4546  public:
    4647    ///
     
    4950    tTest(void);
    5051
    51    
     52
    5253    /**
    5354       Adding a data value to tTest.
     
    6566       Calculates the t-score, i.e. the ratio between difference in
    6667       mean and standard deviation of this difference. The t-score is
    67        calculated as 
     68       calculated as
    6869       \f$ t = \frac{ m_x - m_y }{
    6970       s\sqrt{\frac{1}{n_x}+\frac{1}{n_y}}} \f$ where \f$ m \f$ is the
     
    7677       \see AveragerWeighted
    7778
    78        If all weights are equal to unity this boils down to 
     79       If all weights are equal to unity this boils down to
    7980       \f$ t = \frac{ m_x - m_y }
    8081       {s\sqrt{\frac{1}{n_x}+\frac{1}{n_y}}} \f$ where \f$ m \f$ is
     
    8485
    8586       \see Averager
    86        
     87
    8788       \return t-score.
    8889    */
    89     double score(void); 
     90    double score(void);
    9091
    91     ///
    92     /// Calculates the p-value, i.e. the probability of observing a
    93     /// t-score equally or larger if the null hypothesis is true. If P
    94     /// is near zero, this casts doubt on this hypothesis. The null
    95     /// hypothesis is that the means of the two distributions are
    96     /// equal. Assumtions for this test is that the two distributions
    97     /// are normal distributions with equal variance. The latter
    98     /// assumtion is dropped in Welch's t-test.
    99     ///
    100     /// @return the two-sided p-value
    101     ///
     92    /**
     93       \return the probability of observing a t-score that is equal or
     94       smaller than score().
     95     */
     96    double p_left(void) const;
     97
     98    /**
     99       \return the one-sided p-value, i.e., the probability of
     100       observing a t-score that is equal or greater than observed
     101       here.
     102     */
     103    double p_right(void) const;
     104
     105    /**
     106       Calculates the two-sided p-value, i.e., the probability to
     107       observe a t-score equal (or greater) than |t| or smaller than
     108       -|t|, where t is the observed t-score (returned by score()).
     109
     110     \return the two-sided p-value
     111    */
    102112    double p_value() const;
    103113
    104     ///
    105     /// @return One-sided P-value
    106     ///
    107     double p_value_one_sided(void) const;
     114    /**
     115       \deprecated Provided for backward compatibility with 0.10
     116       API. Use p_right() instead.
     117     */
     118    double p_value_one_sided(void) const YAT_DEPRECATE;
    108119
    109120  private:
     
    114125    AveragerWeighted pos_;
    115126    AveragerWeighted neg_;
    116 
    117127  };
    118128
Note: See TracChangeset for help on using the changeset viewer.