  The chi square goodness-of-fit test is among the oldest known statistical
tests, first proposed by Pearson in 1900 for the multinomial distribution. It
has been in use in many fields ever since. However, various studies have shown
that when applied to data from a continuous distribution it is generally
inferior to other methods such as the Kolmogorov-Smirnov or Anderson-Darling
tests. However, the performance, that is the power, of the chi square test
depends crucially on the way the data is binned. In this paper we describe a
method that automatically finds a binning that is very good against a specific
alternative. We show that then the chi square test is generally competitive and
sometimes even superior to other standard tests.
