diff --git a/src/stats/chi.rs b/src/stats/chi.rs index b867050..ea07c45 100644 --- a/src/stats/chi.rs +++ b/src/stats/chi.rs @@ -25,12 +25,22 @@ fn test_statistic>(table: &ContingencyTable f64 { + if expected_count == 0 { + 1.0 + } else { + expected_count as f64 + } +} + /// calculates the p-value given the test statistic and the degrees of freedom. /// This is determined by the area of the Chi Square distribution (which is a special /// case of the gamma distribution).