# load entropy library
library("entropy")
# observed counts for each bin
y = c(4, 2, 3, 0, 2, 4, 0, 0, 2, 1, 1)
# Dirichlet estimate with a=0
entropy.Dirichlet(y, a=0)
# compare to empirical estimate
entropy.empirical(y)
# Dirichlet estimate with a=1/2
entropy.Dirichlet(y, a=1/2)
# Dirichlet estimate with a=1
entropy.Dirichlet(y, a=1)
# Dirichlet estimate with a=1/length(y)
entropy.Dirichlet(y, a=1/length(y))
# Dirichlet estimate with a=sqrt(sum(y))/length(y)
entropy.Dirichlet(y, a=sqrt(sum(y))/length(y))
# contigency table with counts for two discrete variables
y = rbind( c(1,2,3), c(6,5,4) )
# Dirichlet estimate of mutual information (with a=1/2)
mi.Dirichlet(y, a=1/2)Run the code above in your browser using DataLab