# Changeset 760 for trunk/yat/statistics

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

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

Location:
trunk/yat/statistics
Files:
2 edited

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

 r718 // If a column sum or a row sum is zero, the table is nonsense if ((a==0 || d==0) && (c==0 || b==0)){ //Peter, should throw exception std::cerr << "Warning: Fisher: Table is not valid\n"; return oddsratio_ = 1.0; throw std::runtime_error("runtime_error: Table in Fisher is not valid\n"); } d_++; // If a column sum or a row sum is zero, the table is non-sense if ((a_==0 || d_==0) && (c_==0 || b_==0)){ std::cerr << "Warning: Fisher: Table is not valid\n"; return 1; } return oddsratio(a_,b_,c_,d_); } d_+=value.weight(i); // If a column sum or a row sum is zero, the table is non-sense if ((a_==0 || d_==0) && (c_==0 || b_==0)){ // Peter should throw an exception here std::cerr << "Warning: Fisher: Table is not valid\n"; return 1; } return oddsratio(a_,b_,c_,d_); } d_+=weight(i); // If a column sum or a row sum is zero, the table is non-sense if ((a_==0 || d_==0) && (c_==0 || b_==0)){ // Peter should throw an exception std::cerr << "Warning: Fisher: Table is not valid\n"; return 1; } return oddsratio(a_,b_,c_,d_); }
• ## trunk/yat/statistics/Fisher.h

 r747 /// less than unity 1 divided by odds ratio is returned /// /// @throw If table is invalid a runtime_error is thrown. /// double score(const classifier::Target& target, const utility::vector& value); /// @see score /// /// @throw If table is invalid a runtime_error is thrown. /// double score(const classifier::Target& target, const classifier::DataLookupWeighted1D& value); /// @see score /// /// @throw If table is invalid a runtime_error is thrown. /// double score(const classifier::Target& target, const utility::vector& value, /// @return odds ratio. If absolute_ is true and odds ratio is /// less than unity, 1 divided by odds ratio is returned /// /// @throw If table is invalid a runtime_error is thrown. /// double score(const u_int a, const u_int b,
Note: See TracChangeset for help on using the changeset viewer.