Skip to content

Commit

Permalink
Add ContingencyTable::is_integer() member function to check whether t…
Browse files Browse the repository at this point in the history
…he table contains all integers
  • Loading branch information
JohnHalleyGotway committed Aug 28, 2024
1 parent 38a5d4e commit 5e1d81d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/libcode/vx_statistics/contable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,22 @@ double ContingencyTable::min() const {
return min;
}

////////////////////////////////////////////////////////////////////////

bool ContingencyTable::is_integer() const {
bool status = true;

// Check that each entry contains an integer
for(auto &x : E) {
if(!is_eq(trunc(x), x)) {
status = false;
break;
}
}

return status;
}

////////////////////////////////////////////////////////////////////////
//
// Code for class TTContingencyTable
Expand Down
5 changes: 4 additions & 1 deletion src/libcode/vx_statistics/contable.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

////////////////////////////////////////////////////////////////////////

class TTContingencyTable; // forward reference
// Forward reference
class TTContingencyTable;

////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -93,6 +94,8 @@ class ContingencyTable {
double max() const;
double min() const;

bool is_integer() const;

// Statistics
virtual double gaccuracy () const;
virtual double gheidke () const;
Expand Down

0 comments on commit 5e1d81d

Please sign in to comment.