İki histogramın benzerliği nasıl değerlendirilir?


33

İki histogram verildiğinde, benzer olup olmadıklarını nasıl değerlendirebiliriz?

İki histograma basitçe bakmak yeterli mi? Bire bir haritalamanın basit olması bir histogramın biraz farklı ve biraz kayması durumunda istenen sonucu alamayacağımız sorunudur.

Baska öneri?


2
"Benzer" ne anlama geliyor? Ki-kare testi ve KS testi, örneğin, iki histogramın aynı olup olmadığını test eder . Ancak "benzer" , konum ve / veya ölçek farklılığını göz ardı ederek "aynı şekle sahip" anlamına gelebilir . Niyetini açıklayabilir misin?
whuber

Yanıtlar:


8

Okumaya değer olabilecek yeni bir makale:

Cao, Y. Petzold, L. Doğruluk sınırlamaları ve kimyasal olarak reaksiyona giren sistemlerin stokastik simülasyonunda hataların ölçülmesi, 2006.

Bu çalışmanın odak noktası stokastik simülasyon algoritmalarını karşılaştırmak olmasına rağmen, esas olarak ana fikir iki histogramın nasıl karşılaştırılacağıdır.

PDF'ye yazarın web sayfasından erişebilirsiniz .


Merhaba, güzel yazı, pdf linkini verdiğiniz için teşekkür ederim .. Kesinlikle bu
yazıdan

12
Referans vermek yerine, makalenin ana noktalarını özetlemeniz iyi olur. Bağlantılar ölür, bu nedenle gelecekte cevabınız bu derginin abonesi olmayanlar için yararsız olabilir (ve insan nüfusunun büyük çoğunluğu abonelik dışıdır).
Tim

27

İki histogram arasında birçok mesafe ölçümü vardır. Bu önlemlerin iyi bir sınıflandırmasını şurada okuyabilirsiniz:

K. Meshgi ve S. Ishii, Proc., "İzleme Doğruluğunu Geliştirmek İçin Izgara Renkleriyle Histogramı Genişletmek", Proc. MVA'15, Tokyo, Japonya, Mayıs 2015.

Rahatınız için en popüler mesafe işlevleri burada listelenmiştir:

  • L0 veya Hellinger Mesafe

DL0=ih1(i)h2(i)

  • L1 , Manhattan veya Şehir Bloğu Mesafesi

DL1=i|h1(i)h2(i)|

  • L=2 veya Öklid Uzaklığı

DL2=i(h1(i)h2(i))2

  • L veya Chybyshev Mesafe

DL=maxi|h1(i)h2(i)|

  • L p veya Kesirli Mesafe (Minkowski mesafe ailesinin bir parçası)p

DLp=(i|h1(i)h2(i)|p)1/p ve0<p<1

  • Histogram Kavşağı

D=1i(min(h1(i),h2(i))min(|h1(i)|,|h2(i)|)

  • Kosinüs Mesafe

DCO=1ih1(i)h2(i)

  • Canberra Mesafe

DCB=i|h1(i)h2(i)|min(|h1(i)|,|h2(i)|)

  • Pearson Korelasyon Katsayısı

DCR=i(h1(i)1n)(h2(i)1n)i(h1(i)1n)2i(h2(i)1n)2

  • Kolmogorov-Smirnov Diverganlığı

DKS=maxi|h1(i)h2(i)|

  • Match Distance

DMA=i|h1(i)h2(i)|

  • Cramer-von Mises Distance

DCM=i(h1(i)h2(i))2

  • χ2 Statistics

Dχ2=i(h1(i)h2(i))2h1(i)+h2(i)

  • Bhattacharyya Distance

DBH=1ih1(i)h2(i) & hellinger

  • Squared Chord

DSC=i(h1(i)h2(i))2

  • Kullback-Liebler Divergance

DKL=ih1(i)logh1(i)m(i)

  • Jefferey Divergence

DJD=i(h1(i)logh1(i)m(i)+h2(i)logh2(i)m(i))

  • 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.

DEM=minfiji,jfijAijsumi,jfij jfijh1(i),jfijh2(j),i,jfij=min(ih1(i)jh2(j)) and fij represents the flow from i to j

  • Quadratic Distance

DQU=i,jAij(h1(i)h2(j))2

  • Quadratic-Chi Distance

DQC=i,jAij(h1(i)h2(i)(cAci(h1(c)+h2(c)))m)(h1(j)h2(j)(cAcj(h1(c)+h2(c)))m) and 000

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)

DCB=i|h1(i)h2(i)||h1(i)|+|h2(i)|

  • Bray-Curtis Dissimilarity, Sorensen Distance (since the sum of histograms are equal to one, it equals to DL0)

DBC=12ih1(i)=h2(i)ih1(i)+ih2(i)

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

DIOU=1imin(h1(i),h2(i))imax(h1(i),h2(i))


Welcome to our site! Thank you for this contribution.
whuber


Thanks, a list is wonderful, while it doesn't allow to create a comparison operator for histogram, e.g. to say that hist1 < hist2
Olha Pavliuk

22

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.)


You are correct that the KS test is not appropriate for histograms when it is understood as a hypothesis test about the distribution of the underlying data, but I see no reason why the KS statistic wouldn't work well as a measure of sameness of any two histograms.
whuber

An explanation of why the Kolmogorov-Smirnov test is not appropriate with binned data would be useful.
naught101

This may not be as useful in image processing as in statistical fit assessment. Often in image processing, a histogram of data is used as a descriptor for a region of an image, and the goal is for a distance between histograms to reflect the distance between image patches. Little, or possibly nothing at all, may be known about the general population statistics of the underlying image data used to get the histogram. For example, the underlying population statistics when using histograms of oriented gradients would differ considerably based on the actual content of the images.
ely

1
naught101's question was answered by Stochtastic: stats.stackexchange.com/a/108523/37373
Lapis

10

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.


1
Subtracting the mean changes the null distribution of the KS statistic. @David Wright raises a valid objection to the application of the KS test to histograms anyway.
whuber

7

As David's answer points out, the chi-squared test is necessary for binned data as the KS test assumes continuous distributions. Regarding why the KS test is inappropriate (naught101's comment), there has been some discussion of the issue in the applied statistics literature that is worth raising here.

An amusing exchange began with the claim (García-Berthou and Alcaraz, 2004) that one third of Nature papers contain statistical errors. However, a subsequent paper (Jeng, 2006, "Error in statistical tests of error in statistical tests" -- perhaps my all-time favorite paper title) showed that Garcia-Berthou and Alcaraz (2005) used KS tests on discrete data, leading to their reporting inaccurate p-values in their meta-study. The Jeng (2006) paper provides a nice discussion of the issue, even showing that one can modify the KS test to work for discrete data. In this specific case, the distinction boils down to the difference between a uniform distribution of the trailing digit on [0,9],

P(x)=19, (0x9)
(in the incorrect KS test) and a comb distribution of delta functions,
P(x)=110j=09δ(xj)
(in the correct, modified form). As a result of the original error, Garcia-Berthou and Alcaraz (2004) incorrectly rejected the null, while the chi-squared and modified KS test do not. In any case, the chi-squared test is the standard choice in this scenario, even if KS can be modified to work here.

-1

You can compute the cross-correlation (convolution) between both histograms. That will take into account slight traslations.


1
This is being automatically flagged as low quality, probably because it is so short. At present it is more of a comment than an answer by our standards. Can you expand on it? We can also turn it into a comment.
gung - Reinstate Monica

Since histograms are fairly unstable representations of data, and also because they do not represent probabilities using height alone (they use area), one might reasonably question the applicability, generality, or usefulness of this approach unless more specific guidance is provided.
whuber
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.