# Knuth rule for number of bins of a histogram vs. chi2 fitting

I try to make a histogram and then fit some distribution to it by means of chi2. The Knuth rule (I have some bimodal cases so I'm not using Freedman-Diaconis or Scott) gives me the following histogram (there are 914 data points):

The problem is that there are two bins with less than 5 counts, so it's not really justified to believe a result of a chi2 fitting. How can I cope with this problem? Should I just merge the underpopulated bins with their neighbours (variable bin-widths)? I tried manually playing with the number of (equal-width) bins checking if there's a binning with all the counts $\geq 5$ but with no luck. What about just excluding the data from the underpopulated bins (is it justified to call them outliers?)?

• It seems from your question that you have the actual values and can group them into the histogram as you wish. If so, why do you need to group them into the histogram to fit a distribution? – EdM May 18 '15 at 22:26
• This link gives lots of tips for chi-squared goodness of fit tests. It talks about small cell frequencies and also has a discussion about how to deal continuous data. – Eric Farng May 18 '15 at 22:44
• If you have the underlying data points, forcing them into bins throws away all the information about the distribution within the bins. There is no need to proceed in that way. An answer to this question on fitting distributions to data includes an extensive list of tools available in R for this task without resorting to binning. The discussion on that page contains much useful additional information. – EdM May 19 '15 at 12:14
• Quantile-quantile plots are by far the best way to assess fit to specified distributions. Chi-square testing is essentially useless compared with alternatives. Apart from arbitrary loss of information, It is often insensitive precisely where sensitivity is needed, usually in the tails. Its continued recommendation in some places is hard to fathom. – Nick Cox Dec 13 '19 at 15:54