# Distance measure for binomial data

Assume a distribution for the normal data and test each point $\vec {x}[κ]$ for distance from the mean. A widely used distance measure is the Mahalanobis distance.

If the data are not normal, but binomial could you tell me please if there is a similar distance measure?

• Could you clarify what you mean by "similar"? Could you explain why you think the Mahalanobis distance does not apply to binomial data? For a definition and interpretation of Mahalanobis distance that makes no use of a Normality assumption, please see stats.stackexchange.com/a/62147/919.
– whuber
Oct 21, 2016 at 21:35
• Thanks for your help. I mean an appropriate model for binomial data. I read here books.google.gr/… that this measure works for approximately normal data. Moreover, I read the answer that you proposed and from the 4th bullet it seems that this will not work for my data. Please, correct me if I am wrong.
– F.F.
Oct 22, 2016 at 8:31

As said in comments, maybe just the Mahalanobis distance could work. But, as explained in Intuition of the Bhattacharya Coefficient and the Bhattacharya distance? and other places, often an alternative which might work better is the Bhattacharyya distance based on the Bhattacharyya coefficient $$BC(p,q) = \sum_{k=0}^n \sqrt{p(k) q(k)}$$ here written in the discrete case relevant for the binomial distribution. Now let $$p, q$$ respectively be binomial distributions with the same index $$n$$ and probability parameters $$p,q$$. Then the Bhattacharyya coefficient becomes $$BC(p,q) = \sum_{k=0}^n \binom{n}{k} (pq)^{k/2} ((1-p)(1-q))^{(n-k)/2}$$ which can be simplified to $$BC(p,q) = (\frac{\widetilde{pq}}{\widetilde{(1-p)(1-q)}}+1)^n \widetilde{(1-p)(1-q)}^n$$ where the symbols with a tilde over them represents the geometric mean of $$p,q$$ and of $$(1-p),(1-q)$$, respectively. Then the Bhattacharrya distance is given by $$BD(p,q)= -\ln BC(p,q)$$ You can easily check that if $$p=q$$ then this distance becomes zero.

Below is a plot of this distance function for the case $$n=10$$:

and for the record the R code used to produce it:

 BD <- Vectorize( function(p, q, n) {
PQ  <-  sqrt(p*q)
PQC <-  sqrt((1-p)*(1-q))
-n*log((PQ/PQC)+1) - n*log(PQC)
}
)
x <- y <- seq(0.01, 0.99, by=0.01)
z <- outer(x, y, FUN=function(x, y) BD(x, y, 10))
levels <- c(seq(0.1, 1.5, by=0.2), 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5)
image(x, y, z, col=terrain.colors(15), xlab="p", ylab="q" )
title("Bhattacharyya distance between binomial n=10")