# What is the correct way to modify the bin-counts given a threshold for a chi-squared test?

When performing a chi-square test, one inputs the expected counts (via integrating probability distribution over respective bin bounds) and observed counts into the chi-square formula (denoted below).

I am told by a friend that when performing a chi-square test, one must impose a threshold such that any bin counts less than the threshold are consolidated into the next bin.

I tried looking this up via various permutations of search keywords “adaptive binning threshold count chi-square” but without much success.

I am unclear on whether a bin count less than the threshold means that bin count is effectively zero, or if the bin (or bin-width) merges. As an example, suppose the bin count threshold is 5:

original bin-edges = [0, 5, 10, 15, 20, 25]
original bin-midpoints = [2.5, 7.5, 12.5, 17.5, 22.5]
original bin counts = [3, 15, 26, 18, 2]


The first option is to consolidate the bins like so:

modified bin-edges = original bin-edges
modified bin-midpoints = original bin-midpoints
modified bin counts = [0, 18, 26, 20, 0]


The second option is to consolidate the bins like so:

modified bin-edges = [0, 10, 15, 25]
modified bin-midpoints = [5, 12.5, 20]
modified bin counts = [18, 26, 20]
# note the unequal bin-widths


Are either of these two methods correct when considering a minimized chi-squared?

This brings me to my next related question. Assuming a distribution with a central peak, should one consolidate bins to their respective next-right bin if in the left-side tail and consolidate bins to their respective next-left bin if in the right-side tail? If not, what is the proper procedure?

While the threshold is supposed to be small (typically ~5, sometimes less), can this hide information in a distribution tail in other distributions (say, lognormal distribution)?