View License

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

» Watch video

Highlights from
Normalized Mutual Information

  • nmi(x, y)Compute normalized mutual information I(x,y)/sqrt(H(x)*H(y)) of two discrete variables x and y.
  • View all files
4.2 | 6 ratings Rate this file 57 Downloads (last 30 days) File Size: 734 Bytes File ID: #29047 Version: 1.0

Normalized Mutual Information


Mo Chen (view profile)


15 Oct 2010 (Updated )

Fully vectorized implementation NMI. NMI is often used for evaluating clustering results.

| Watch this File

File Information

Normalized mutual information is often used for evaluating clustering results, information retrieval, feature selection etc. This is a optimized implementation of the function which has no for loops.
This function is now a part of the PRML toolbox (


Pattern Recognition And Machine Learning Toolbox inspired this file.

This file inspired Information Theory Toolbox.

MATLAB release MATLAB 9.0 (R2016a)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (13)
16 Aug 2016 Albert Pun

Would appreciate more comments and some examples

03 Jun 2016 Sowmya Ravindra

I am trying to find similarities between two signals obtained from two different modalities and sampling frequencies.Hence tried the mutual information code. but i get an error : 'Error using sparse
Sparse matrix sizes must be non-negative integers less than MAXSIZE as defined by COMPUTER. Use HELP COMPUTER for more details.

Error in nmi (line 20)
Mx = sparse(idx,x,1,n,k,n);'

Please help me correct this error.

Comment only
25 Mar 2015 samira rahimi

15 Dec 2014 Ori

Ori (view profile)

Why is it important to verify the integrity of results, i.e. length(labels)==length(results)?

Isn't it possible to use nmi for clustering with k that is different from number of labels?

I changed the script for my use so that it will accept this. should I upload?

Comment only
11 Sep 2014 Jianxiong Chen

please add more comments, especially for the inputs. Thanks

Comment only
01 Jul 2014 bao dinh


Comment only
08 Nov 2013 Kelvin Wong

It doesn't work for large matrix as it rans out of memory in line 16 and 17.

11 Aug 2013 yang

yang (view profile)

29 Dec 2011 Eric Chen

grateful if more comments provided

21 Nov 2011 Artur Abdullin

Good job, I used your function to validate mine :). Sometime in research you cannot trust even yourself.

07 Sep 2011 Md. Ali Hossain

Can you give a detailed docomented .m file so that we can have a easy understanding of NMI.


Comment only
23 Jun 2011 NR P

NR P (view profile)

I agree, an example... and a little description of the inputs would be strongly appreciated! Thank you!

Comment only
23 Jun 2011 Zhi

Zhi (view profile)

Could you provide some examples of running your code to prove it is correct?

Comment only
07 Mar 2016 1.0

minor tweak

Contact us