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

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

File:
1 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  }
Note: See TracChangeset for help on using the changeset viewer.