Changeset 98 for trunk/src/ROC.cc


Ignore:
Timestamp:
Jun 10, 2004, 5:24:05 PM (19 years ago)
Author:
Peter
Message:

tScore added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ROC.cc

    r78 r98  
    22
    33// System includes
    4 #include <algorithm>
    5 #include <utility>
    6 #include <vector>
     4//#include <algorithm>
     5//#include <utility>
     6//#include <vector>
    77
    88// Thep C++ Tools
     
    1616  ROC::ROC(const gslapi::vector& target, const gslapi::vector& value)
    1717 
    18     : value_(), nof_pos_(0), minimum_size_(10)
     18    : Score(), value_(), nof_pos_(0), minimum_size_(10), area_(-1)
    1919
    2020       
     
    3333
    3434
    35   double ROC::area()
     35  double ROC::score()
    3636  {
    3737    using namespace std;
    38     double area=0;
    39     for (unsigned int i=0; i<value_.size(); i++)
    40       if (value_[i].first==1)
    41         area+=i;
    42     // Normalizing the area to 0-1
    43     area = (area/nof_pos_ - (nof_pos_ - 1)/2 )/(value_.size() - nof_pos_);
    44 
    45     return area;
     38    if (area_==-1){
     39      double area_=0;
     40      for (unsigned int i=0; i<value_.size(); i++)
     41        if (value_[i].first==1)
     42          area_+=i;
     43      // Normalizing the area to 0-1
     44      area_ = (area_/nof_pos_ - (nof_pos_ - 1)/2 )/(value_.size() - nof_pos_);
     45    }
     46    return area_;
    4647  }
    4748
    4849
    49   double ROC::get_p(const double area)
     50  double ROC::p_value(void)
    5051  {
     52    if (area_==-1)
     53      area_ = score();
    5154    double p;
    5255    if (nof_pos_ < minimum_size_ & value_.size()-nof_pos_ < minimum_size_)
    53       p = get_p_exact(area*nof_pos_*(value_.size()-nof_pos_),
     56      p = get_p_exact(area_*nof_pos_*(value_.size()-nof_pos_),
    5457                          nof_pos_, value_.size()-nof_pos_);
    5558    else
    56     p = get_p_approx(area);
     59    p = get_p_approx(area_);
    5760    return p;
    5861  }
Note: See TracChangeset for help on using the changeset viewer.