File Exchange

## Kullback-Leibler Divergence

version 1.0.0.0 (541 Bytes) by Nima Razavi

### Nima Razavi (view profile)

Calculates the Kullback-Leibler Divergence between two probability distributions

Updated 15 Jul 2008

For the description of the divergence you can take a look at :
http://en.wikipedia.org/wiki/Kullback-Leibler_divergence

### Mohammad Ali Kawser (view profile)

getting multiple outputs, aint it supposed to give a single value for distance? How to get that, if anyone may help?

Jahandar Jahanipour

zeeshan akhtar

mohamed abu eita

zheng nianzu

Jonathan DuBois

### Jonathan DuBois (view profile)

Thank you for submitting this, however I was wondering what is the reason for the line: P = P ./repmat(sum(P,2),[1 size(P,2)]);?
This doesn't seem to be a part of other KLdiv calculations.

t h

sailer

### sailer (view profile)

It will be better to give an example

Aminullah khan

hello_world

### hello_world (view profile)

I have two probability matrix P and Q of size m x n and q x n each. How to calculate KL-divergence for these two matrices?

Erkin

### Erkin (view profile)

Shouldn't the log value be log2 instead of natural logarithm?

wang

### wang (view profile)

Sir, can you give a detailed description of P and Q in this function? example better.

Maysam Shahedi

### Maysam Shahedi (view profile)

dear sir we need kld for feature selection in MRI brain image can some one help me

Hung nguyen

Nate Greene

### Nate Greene (view profile)

Please note that the logarithms should be base 2 if calculating values in bits.

Dimitri Shvorob

Your implementation is third of its kind on FEX: please take time to search FEX for existing code before posting.

 15 Jul 2008 1.0.0.0 BUG_FIXED
##### MATLAB Release Compatibility
Created with R2007a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux