Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I would like to know what are the common techniques to compare two histograms? I have histogram of two images and I want to see are they similar or not meaning that is there any correlation between them or not. The histograms are for two different parts of tissue.

enter image description here

share|improve this question
1  
I think this answer applies to your question as well: stats.stackexchange.com/questions/99777/… –  juampa Aug 18 at 6:51

2 Answers 2

up vote 3 down vote accepted

If you understand a graphical technique under ''comparison'' you should probably try a QQ-plot (qqplot under R).

If you are thinking of an analytical way (i.e. statistical test), the two-sample Kolmogorov-Smirnov test is the most classical way (ks.test under R). There are other, more modern goodness-of-fit tests (this is how your task called statistically, this case in a two-sample sense) available, such as Anderson-Darling test (ad.test from the package kSamples).

You might also consider binning the data (with cut) and then performing a $\chi^2$-squared test (chisq.test).

(If you don't want to compare the whole distribution, just some characteristics, such as the mean or variance, you get back to elementary statistical tests. Also note that the above was a non-parametrical approach; if you're willing to assume some functional form for the distributions, you can also use classical tests.)

Note that for very large sample sizes (which might be the case judging from your histogram) you will likely obtain significant results from every test. (They'll have extremely high power, detecting even minuscule deviations from the null.) In that case, graphical techniques (QQ-plot) might be still useful to decide how large is the deviation.

share|improve this answer
    
I have one question should I plot qqplot for horizontal value or vertical value meaning x value or y value ? –  user59419 Aug 18 at 7:54
    
The two parameter of qqplot is the two sample you have, i.e. a vector of the values (ranging from 0 to 1 if I see your histogram correctly). Whether you use qqplot(x,y) or qqplot(y,x) doesn't really matter, the two plot will be mirrored. –  Tamas Ferenci Aug 18 at 9:23
    
I thought qqplot(x1,x2) means x1 is from one sample and x2 is from the other and not x and y of the same histogram.is that right? –  user59419 Aug 18 at 10:32
    
@user59419 : Yes, x1 is the data behind the red histogram on the image you posted, x2 is the data behind the blue histogram (or the other way around). –  Tamas Ferenci Aug 18 at 10:41

Some common measures of histogram discrepancy or agreement include

Earth mover's distance

Bhattacharyya distance

Chi-square distance, $d(x,y) = \frac{1}{2}\sum_i \frac{(x_i-y_i)^2}{x_i+y_i}$

Kullback-Leibler divergence

There are many others.

share|improve this answer
    
Very good point indeed. These can be used to quantify the similarity (if you need numerical ''answer'' to that question). –  Tamas Ferenci Aug 18 at 10:53
    
@Tamas Once you have a statistic/measure that gives an ordering (histogram B is more like histogram A than histogram C is), you can have a test of equality based off it (e.g. a permutation/randomization test). –  Glen_b Aug 18 at 11:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.