Computes the sample entropy (sampen), as given by Richman & Moorman (2000), doi:10.1152/ajpheart.2000.278.6.H2039 .
Usage
sampen(
timeseries_array,
dimensions = 2,
tolerance = 0.2,
standardize = TRUE,
use_diff = FALSE
)
Arguments
- timeseries_array
Array of numbers over which the sampen is to be computed.
- dimensions
Number of embedding dimensions for which to compute the sampen. Sometimes also called "template length".
- tolerance
Tolerance for the comparisons of two number sequences.
- standardize
Whether to standardize the timeseries_array.
- use_diff
Whether to use the differences between adjacent points.
Details
As suggested by Richman & Moorman (2000),
doi:10.1152/ajpheart.2000.278.6.H2039
, the last possible vector of length
dimensions
is not considered because it has no corresponding vector of
length dimensions + 1
, ensuring a sampen estimation with a low bias
introduced by the length of the timeseries_array
.
The function was deliberately implemented in R with C-style code. While this
makes the function rather slow for large timeseries_array
s,
it enables maximal transparency. For an overview over faster sampen
functions in R that, however, are distributed in binary or need source
compilation, see Chen et al. (2019), doi:10.1093/biomethods/bpz016
.
References
Pfister, R., Tonn, S., Schaaf, M., Wirth, R. (2024). mousetRajectory: Mouse tracking analyses for behavioral scientists. The Quantitative Methods for Psychology, 20(3), 217-229. doi:10.20982/tqmp.20.3.p217
Examples
x_vals <- rep(c(0, 0, 0, 0, 0, 1), 20)
sampen(x_vals, dimensions = 1, tolerance = 1 / 2, standardize = FALSE)
#> [1] 0.3746047
sampen(x_vals, dimensions = 3, tolerance = 1 / 2, standardize = FALSE)
#> [1] 0.4314233
sampen(x_vals,
dimensions = 3, tolerance = 1 / 2, standardize = FALSE,
use_diff = TRUE
)
#> [1] 0.319137
sampen(x_vals, dimensions = 3, tolerance = 1, standardize = FALSE)
#> [1] 0