$$I(x) = -\log p(x)$$ Shannon (1948), Section 6; Cover & Thomas (2006), p. 14, where the entropy is the expectation of -log p(X).
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
M <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2)
Surpris(V, M)
#> $estimate
#> [1] 3.120057
#>
#> $values
#> [1] 4.169925 3.584963 3.169925 2.847997 2.584963 2.362570
#>
#> $entropy
#> [1] 2.794209
#>
#> $n
#> [1] 6
#>
#> $method
#> [1] "Surprisal -log p(x) -- Shannon (1948) Sec. 6"
#>
