Skip to content
Prev 54531 / 63424 Next

Numerical stability in chisq.test

The preceding 2 lines seem relevant:

            ## Sorting before summing may look strange, but seems to be
            ## a sensible way to deal with rounding issues (PR#3486):
            STATISTIC <- sum(sort((x - E) ^ 2 / E, decreasing = TRUE))

-k