# NOT RUN {
probs.tmp <- rexp(5)
probs.tmp <- sort(probs.tmp / sum(probs.tmp))
unif.distr <- rep(1/length(probs.tmp), length(probs.tmp))
matplot(cbind(probs.tmp, unif.distr), pch = 19,
ylab = "P(X = k)", xlab = "k")
matlines(cbind(probs.tmp, unif.distr))
legend("topleft", c("non-uniform", "uniform"), pch = 19,
lty = 1:2, col = 1:2, box.lty = 0)
discrete_entropy(probs.tmp)
# uniform has largest entropy among all bounded discrete pmfs
# (here = log(5))
discrete_entropy(unif.distr)
# no uncertainty if one element occurs with probability 1
discrete_entropy(c(1, 0, 0))
# }
Run the code above in your browser using DataLab