Compute a rolling kurtosis
Description
The window at a given row will include the row itself, and the
window_size - 1 elements before it.
Usage
<Expr>$rolling_kurtosis(
window_size,
...,
fisher = TRUE,
bias = TRUE,
min_samples = NULL,
center = FALSE
)
Arguments
window_size
|
The length of the window in number of elements. |
…
|
These dots are for future extensions and must be empty. |
fisher
|
If TRUE (default), Fisher’s definition is used (normal ==\>
0.0). If FALSE, Pearson’s definition is used (normal ==\>
3.0).
|
bias
|
If FALSE, the calculations are corrected for statistical
bias.
|
min_samples
|
The number of values in the window that should be non-null before
computing a result. If NULL (default), it will be set equal
to window_size.
|
center
|
If TRUE, set the labels at the center of the window.
|
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(a = c(1, 4, 2, 9))
df$with_columns(
rolling_kurtosis = pl$col("a")$rolling_kurtosis(window_size = 3)
)
#> shape: (4, 2)
#> ┌─────┬──────────────────┐
#> │ a ┆ rolling_kurtosis │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪══════════════════╡
#> │ 1.0 ┆ null │
#> │ 4.0 ┆ null │
#> │ 2.0 ┆ -1.5 │
#> │ 9.0 ┆ -1.5 │
#> └─────┴──────────────────┘
# Center the values in the window
df$with_columns(
rolling_kurtosis = pl$col("a")$rolling_kurtosis(window_size = 3, center = TRUE)
)
#> shape: (4, 2)
#> ┌─────┬──────────────────┐
#> │ a ┆ rolling_kurtosis │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪══════════════════╡
#> │ 1.0 ┆ null │
#> │ 4.0 ┆ -1.5 │
#> │ 2.0 ┆ -1.5 │
#> │ 9.0 ┆ null │
#> └─────┴──────────────────┘