Learn R Programming

habtools (version 1.1.1)

entropy_1d: 1D Entropy

Description

Calculates entropy in 1 dimension

Usage

entropy_1d(x, grid_size, relative = FALSE)

Value

Entropy value.

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

Run this code
x <- rnorm(1000, 5, 1)
entropy_1d(x, grid_size = 0.1)
entropy_1d(x, grid_size = 0.1, relative = TRUE)
y <- runif(1000, 1, 10)
entropy_1d(y, grid_size = 0.1)
entropy_1d(y, grid_size = 0.1, relative = TRUE)

Run the code above in your browser using DataLab