Skip to contents

Samples P = <p1, p2, ..., pk> from Dirichlet distribution with parameter alpha = <alpha1, alpha2, ..., alphak> can be treated as categorical probability distributions with entropy H(P) = sum(-p log(p)). This function calculates the expected entropy EH(P) given alpha.

Usage

expected_entropy(alpha, k = NULL)

Arguments

alpha

Dirichlet parameter

k

If length(alpha) is 1, number of components in symmetric Dirichlet distribution

Value

Expected entropy EH(P) in bits (log2 scale)

Examples

alpha = peak_alpha(50, 1)
set.seed(1357)
rdirichlet(500, alpha) |>
  apply(1, entropy) |>
  mean()
#> [1] 0.4568703
expected_entropy(alpha)
#> [1] 0.445642