No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Kullback-Leibler Divergence

3.8 | 7 ratings Rate this file 103 Downloads (last 30 days) File Size: 982 Bytes File ID: #20688 Version: 1.0

Kullback-Leibler Divergence


Nima Razavi (view profile)


13 Jul 2008 (Updated )

Calculates the Kullback-Leibler Divergence between two probability distributions

| Watch this File

File Information

For the description of the divergence you can take a look at :

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
13 Jan 2017 Jonathan DuBois

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.

30 Dec 2016 t h

t h (view profile)

21 Nov 2016 sailer

sailer (view profile)

It will be better to give an example

18 Oct 2016 Aminullah khan

03 Dec 2014 hello_world

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?

27 Apr 2014 Erkin

Erkin (view profile)

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

Comment only
18 Apr 2014 wang

wang (view profile)

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

Comment only
07 Aug 2013 Maysam Shahedi

Maysam Shahedi (view profile)

18 Oct 2011 amjad khan

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

Comment only
07 May 2011 Hung nguyen

07 Mar 2011 Nate Greene

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

Comment only
14 Jul 2008 Dimitri Shvorob

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

Comment only

Contact us