Changeset 760 for trunk/yat/statistics


Ignore:
Timestamp:
Feb 20, 2007, 10:58:33 AM (15 years ago)
Author:
Peter
Message:

throw exception when detecting invalid 2x2 table. Fixes #26

Location:
trunk/yat/statistics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/Fisher.cc

    r718 r760  
    7474    // If a column sum or a row sum is zero, the table is nonsense
    7575    if ((a==0 || d==0) && (c==0 || b==0)){
    76       //Peter, should throw exception
    77       std::cerr << "Warning: Fisher: Table is not valid\n";
    78       return oddsratio_ = 1.0;
     76      throw std::runtime_error("runtime_error: Table in Fisher is not valid\n");
    7977    }
    8078
     
    157155          d_++;
    158156       
    159     // If a column sum or a row sum is zero, the table is non-sense
    160     if ((a_==0 || d_==0) && (c_==0 || b_==0)){
    161       std::cerr << "Warning: Fisher: Table is not valid\n";
    162       return 1;
    163     }
    164 
    165157    return oddsratio(a_,b_,c_,d_);
    166158  }
     
    183175          d_+=value.weight(i);
    184176       
    185     // If a column sum or a row sum is zero, the table is non-sense
    186     if ((a_==0 || d_==0) && (c_==0 || b_==0)){
    187       // Peter should throw an exception here
    188       std::cerr << "Warning: Fisher: Table is not valid\n";
    189       return 1;
    190     }
    191 
    192177    return oddsratio(a_,b_,c_,d_);
    193178  }
     
    211196          d_+=weight(i);
    212197       
    213     // If a column sum or a row sum is zero, the table is non-sense
    214     if ((a_==0 || d_==0) && (c_==0 || b_==0)){
    215       // Peter should throw an exception
    216       std::cerr << "Warning: Fisher: Table is not valid\n";
    217       return 1;
    218     }
    219 
    220198    return oddsratio(a_,b_,c_,d_);
    221199  }
  • trunk/yat/statistics/Fisher.h

    r747 r760  
    124124    /// less than unity 1 divided by odds ratio is returned
    125125    ///
     126    /// @throw If table is invalid a runtime_error is thrown.
     127    ///
    126128    double score(const classifier::Target& target,
    127129                 const utility::vector& value);
     
    136138    /// @see score
    137139    ///
     140    /// @throw If table is invalid a runtime_error is thrown.
     141    ///
    138142    double score(const classifier::Target& target,
    139143                 const classifier::DataLookupWeighted1D& value);
     
    149153    /// @see score
    150154    ///
     155    /// @throw If table is invalid a runtime_error is thrown.
     156    ///
    151157    double score(const classifier::Target& target,
    152158                 const utility::vector& value,
     
    158164    /// @return odds ratio. If absolute_ is true and odds ratio is
    159165    /// less than unity, 1 divided by odds ratio is returned
     166    ///
     167    /// @throw If table is invalid a runtime_error is thrown.
    160168    ///
    161169    double score(const u_int a, const u_int b,
Note: See TracChangeset for help on using the changeset viewer.