Q:

How to assess the similarity of two histograms?

Given two histograms, how do we assess whether they are similar or not?
Is it sufficient to simply look at the two histograms?
The simple one to one mapping has the problem that if a histogram is slightly different and slightly shifted then we'll not get the desired result.
Any suggestions?

A:

There are plenty of distance measures between two histogram. You can read a good categorization of these measures in:

K. Meshgi, and S. Ishii, “Expanding Histogram of Colors with Gridding
  to Improve Tracking Accuracy,” in Proc. of MVA’15, Tokyo, Japan, May
  2015.

The most popular distance functions are listed here for your convenience:

$L_0$　or Hellinger Distance

$D_{L0} = \sum\limits_{i} h_1(i) \neq h_2(i) $

$L_1$, Manhattan, or City Block Distance

$D_{L1} = \sum_{i}\lvert h_1(i) - h_2(i) \rvert  $

$L=2$ or Euclidean Distance

$D_{L2} = \sqrt{\sum_{i}\left( h_1(i) - h_2(i) \right) ^2 }$ 

L$_{\infty}$ or Chybyshev Distance

$D_{L\infty} = max_{i}\lvert h_1(i) - h_2(i) \rvert  $

L$_p$ or Fractional Distance (part of Minkowski distance family)

$D_{Lp} = \left(\sum\limits_{i}\lvert h_1(i) - h_2(i) \rvert ^p \right)^{1/p}$ and $0<p<1$

Histogram Intersection

$D_{\cap} = 1 - \frac{\sum_{i} \left(min(h_1(i),h_2(i) \right)}{min\left(\vert h_1(i)\vert,\vert h_2(i) \vert \right)}$

Cosine Distance

$D_{CO} = 1 - \sum_i h_1(i)h2_(i)$

Canberra Distance

$D_{CB} = \sum_i \frac{\lvert h_1(i)-h_2(i) \rvert}{min\left( \lvert h_1(i)\rvert,\lvert h_2(i)\rvert  \right)}$

Pearson's Correlation Coefficient

$ D_{CR} = \frac{\sum_i \left(h_1(i)- \frac{1}{n} \right)\left(h_2(i)- \frac{1}{n} \right)}{\sqrt{\sum_i \left(h_1(i)- \frac{1}{n} \right)^2\sum_i \left(h_2(i)- \frac{1}{n} \right)^2}} $ 

Kolmogorov-Smirnov Divergance 

$ D_{KS} = max_{i}\lvert h_1(i) - h_2(i) \rvert  $ 

Match Distance

$D_{MA} = \sum\limits_{i}\lvert h_1(i) - h_2(i) \rvert  $

Cramer-von Mises Distance

$D_{CM} = \sum\limits_{i}\left( h_1(i) - h_2(i) \right)^2$ 

$\chi^2$ Statistics

$D_{\chi^2} = \sum_i \frac{\left(h_1(i) - h_2(i)\right)^2}{h_1(i) + h_2(i)}$

Bhattacharyya Distance

$ D_{BH} = \sqrt{1-\sum_i \sqrt{h_1(i)h_2(i)}} $ & hellinger

Squared Chord

$ D_{SC} = \sum_i\left(\sqrt{h_1(i)}-\sqrt{h_2(i)}\right)^2 $

Kullback-Liebler Divergance

$D_{KL} = \sum_i h_1(i)log\frac{h_1(i)}{m(i)}$

Jefferey Divergence

$D_{JD} = \sum_i \left(h_1(i)log\frac{h_1(i)}{m(i)}+h_2(i)log\frac{h_2(i)}{m(i)}\right)$ 

Earth Mover's Distance (this is the first member of Transportation distances that embed binning information $A$ into the distance, for more information please refer to the abovementioned paper or Wikipedia entry.

$ D_{EM} = \frac{min_{f_{ij}}\sum_{i,j}f_{ij}A_{ij}}{sum_{i,j}f_{ij}}$
$ \sum_j f_{ij} \leq h_1(i) , \sum_j f_{ij} \leq h_2(j) , \sum_{i,j} f_{ij} = min\left( \sum_i h_1(i) \sum_j h_2(j) \right) $ and $f_{ij}$ represents the flow from 
$i$ to $j$

Quadratic Distance 

$D_{QU} = \sqrt{\sum_{i,j} A_{ij}\left(h_1(i) - h_2(j)\right)^2}$ 

Quadratic-Chi Distance

$D_{QC} = \sqrt{\sum_{i,j} A_{ij}\left(\frac{h_1(i) - h_2(i)}{\left(\sum_c A_{ci}\left(h_1(c)+h_2(c)\right)\right)^m}\right)\left(\frac{h_1(j) - h_2(j)}{\left(\sum_c A_{cj}\left(h_1(c)+h_2(c)\right)\right)^m}\right)}$ and $\frac{0}{0} \equiv 0$
A Matlab implementation of some of these distances is available from my GitHub repository:
https://github.com/meshgi/Histogram_of_Color_Advancements/tree/master/distance
Also you can search guys like Yossi Rubner, Ofir Pele, Marco Cuturi and Haibin Ling for more state-of-the-art distances.
Update: Alternative explaination for the distances appears here and there in the literature, so I list them here for sake of completeness.

Canberra distance (another version)

$D_{CB}=\sum_i \frac{|h_1(i)-h_2(i)|}{|h_1(i)|+|h_2(i)|}$

Bray-Curtis Dissimilarity, Sorensen Distance (since the sum of histograms are equal to one, it equals to $D_{L0}$)

$D_{BC} = 1 - \frac{2 \sum_i h_1(i) = h_2(i)}{\sum_i h_1(i) + \sum_i h_2(i)}$

Jaccard Distance (i.e. intersection over union, another version)

$D_{IOU} = 1 - \frac{\sum_i min(h_1(i),h_2(i))}{\sum_i max(h_1(i),h_2(i))}$

A:

The standard answer to this question is the chi-squared test. The KS test is for unbinned data, not binned data. (If you have the unbinned data, then by all means use a KS-style test, but if you only have the histogram, the KS test is not appropriate.)

A:

You're looking for the Kolmogorov-Smirnov test. Don't forget to divide the bar heights by the sum of all observations of each histogram.
Note that the KS-test is also reporting a difference if e.g. the means of the distributions are shifted relative to one another. If translation of the histogram along the x-axis is not meaningful in your application, you may want to subtract the mean from each histogram first. 

