Skip to contents

-sum(p log2 p) over the histogram probabilities.

Usage

morie_dsp_entropy_histogram(x, n_bins = 50L)

Arguments

x

Numeric vector.

n_bins

Number of bins. Default 50.

Value

Scalar (bits).

References

Rangayyan & Krishnan (2015), Ch. 5, sec. 5.6.

Examples

set.seed(1)
uni <- runif(2000, min = -1, max = 1)
norm <- rnorm(2000)
Hu <- morie_dsp_entropy_histogram(uni, n_bins = 20L)
Hn <- morie_dsp_entropy_histogram(norm, n_bins = 20L)
c(uniform = Hu, gaussian = Hn)  # uniform has higher entropy
#>  uniform gaussian 
#> 4.316644 3.572136