Skip to content

Rolling skew

Source code

Description

Compute the rolling (= moving) skewness over the values in this array. A window of length window_size will traverse the array.

Usage

<Expr>$rolling_skew(window_size, bias = TRUE)

Arguments

window_size The length of the window. Can be a fixed integer size, or a dynamic temporal size indicated by the following string language:
  • 1ns (1 nanosecond)
  • 1us (1 microsecond)
  • 1ms (1 millisecond)
  • 1s (1 second)
  • 1m (1 minute)
  • 1h (1 hour)
  • 1d (1 day)
  • 1w (1 week)
  • 1mo (1 calendar month)
  • 1y (1 calendar year)
  • 1i (1 index count) If the dynamic string language is used, the by and closed arguments must also be set.
bias If FALSE, the calculations are corrected for statistical bias.

Details

For normally distributed data, the skewness should be about zero. For uni-modal continuous distributions, a skewness value greater than zero means that there is more weight in the right tail of the distribution.

Value

Expr

Examples

library(polars)

pl$DataFrame(a = c(1, 3, 2, 4, 5, 6))$
  with_columns(roll_skew = pl$col("a")$rolling_skew(window_size = 2))
#> shape: (6, 2)
#> ┌─────┬───────────┐
#> │ a   ┆ roll_skew │
#> │ --- ┆ ---       │
#> │ f64 ┆ f64       │
#> ╞═════╪═══════════╡
#> │ 1.0 ┆ null      │
#> │ 3.0 ┆ 0.0       │
#> │ 2.0 ┆ 0.0       │
#> │ 4.0 ┆ 0.0       │
#> │ 5.0 ┆ 0.0       │
#> │ 6.0 ┆ 0.0       │
#> └─────┴───────────┘