Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using the ksdensity function in matlab returns a density estimation in the form of 2 vectors f and xi. Where f are the density values and xi the corresponding points for the density values.

How do I calculate the hellinger distance between 2 density estimations based on their f and xi ?

share|improve this question

If you are using Gaussian kernels, then your KDE is a Gaussian mixture model. You can calculate the approximation of the Hellinger divergence by the unscented transform directly on your KDE (without first tabulating to f). There is a pretty fast Matlab code for doing that:

This might be a better option, since your f might not be evaluated over the same range of xi values. However if it is, then the just use the simple formula. Lets say that $f = \{f_i\}_i$ and $g=\{g_i\}_i$ are the two tabulated densities over the same range of $x_i$ values. The Hellinger distance is $H = \sum\limits_i(\sqrt{f_i}-\sqrt{g_i})^2$ .

share|improve this answer
It is true. Just codes in… do not work at all – user26270 May 29 '13 at 15:57

Your Answer


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.