Calculates entropy in 1 dimension
Usage
entropy_1d(x, grid_size, relative = FALSE)
Arguments
- x
A numeric vector.
- grid_size
Bin size in the same unit as the data.
- relative
Logical. Rescale entropy relative to the maximum entropy
given the number of grid cells? Defaults to FALSE.
Examples
x <- rnorm(1000, 5, 1)
entropy_1d(x, grid_size = 0.1)
#> [1] 3.675762
entropy_1d(x, grid_size = 0.1, relative = TRUE)
#> [1] 0.890633
y <- runif(1000, 1, 10)
entropy_1d(y, grid_size = 0.1)
#> [1] 4.439692
entropy_1d(y, grid_size = 0.1, relative = TRUE)
#> [1] 0.9818442