def G_fit(self, williams=True): """performs the goodness-of-fit G test Parameters ---------- williams : bool Applies Williams correction for small sample size """ obs = self.observed.array G, pval = G_fit(obs.flatten(), self.expected.array.flatten(), williams=williams) title = "G-test goodness-of-fit" if williams: title = f"{title} (with Williams correction)" return TestResult( self.observed, self.expected, self.residuals, "G", G, self.df, pval, test_name=title, )
def G_fit(self, pseudo_count=0, williams=True): """performs the goodness-of-fit G test""" assert type(pseudo_count) == int, f"{pseudo_count} not an integer" obs = self.observed.array if pseudo_count: obs += pseudo_count G, pval = G_fit(obs.flatten(), self.expected.array.flatten(), williams=williams) title = "G-test goodness-of-fit" if williams: title = f"{title} (with Williams correction)" result = TestResult( self.observed, self.expected, self.residuals, "G", G, self.df, pval, test_name=title, ) return result