# Distance Between 1-D Histograms and Binning

In order to calculate the distance between two 1-D histograms, they must have the same number of bins. I'm wondering if it's preferable to have more or fewer bins for such calculation.

For example, suppose the Freedman-Diaconis estimator (or another estimator, e.g., Sturges' rule) yields a histogram A with 9 bins and a histogram B with 8 bins. I'd like to calculate the Jensen-Shannon distance between them. Should I increase the number of bins of histogram A to 9, or decrease the number of bins of B to 8? By "increasing" or "decreasing" the number of bins I mean recomputing the histograms with the new number of bins. Any other suggestions are welcome.

• The meaning of "preferable" depends on the objectives of your calculation: what is the purpose? – whuber Apr 11 '18 at 17:36
• The overall goal is to check the extent that two distributions change with time. And by "preferable" I mean if there's perhaps a correct or more theoretically sound way of thinking about the binning approach. – Bruno Apr 11 '18 at 19:00
• Then don't use histograms! Edit your post to ask the question you really need answered. – whuber Apr 11 '18 at 19:06
• Well, I guess I wouldn't need to get histograms specifically as density estimators and then calculate their distance. Maybe a two-sample KS test would do. – Bruno Apr 11 '18 at 19:31
• Specially since the data are continuous anyway. – Bruno Apr 11 '18 at 20:24