Skip to contents

$$-\sum p \log q = H(p) + D(p\|q)$$ Cover & Thomas (2006), eq. (2.1) and (2.26).

Usage

Crsent(p, q, base = 2)

Arguments

p, q

Non-negative vectors of the same length; each closed here.

base

Log base; 2 gives bits.

Value

Named list with estimate, entropy, kl, n, method.

References

Cover & Thomas (2006), eq. (2.26).

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Crsent(V, V)
#> $estimate
#> [1] 2.794209
#> 
#> $entropy
#> [1] 2.794209
#> 
#> $kl
#> [1] 0
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Cross entropy H(p) + D(p||q) -- Cover & Thomas (2006) eq. (2.26)"
#>