Try giving this a read or a browse or whatever.
Looks like what you're after.
Sorry if it's not. http://en.wikipedia.org/wiki/Entropy...tion_theory%29
Or just search for: information entropy and read some tutorials or explanations.
The function H(x) = - (sum of all the values of Pi x Log Pi for each value of "i" where "i" is a variable starting from 1, with increments of 1, up till the value n)