Calculates the Shannon entropy over data of a discrete random variable X.
X
shannonEntropy(x)
x
A discrete vector.
set.seed(1) x = round((runif(1000, min=0, max=5))) shannonEntropy(x=x) ## 2.522265