Skip to content

Compute the skewness

Description

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

Usage

<Expr>$skew(..., bias = TRUE)

Arguments

These dots are for future extensions and must be empty.
bias If FALSE, the calculations are corrected for statistical bias.

Details

The sample skewness is computed as the Fisher-Pearson coefficient of skewness, i.e.

$g_1=\frac{m_3}{m_2^{3/2}}$ where

$m_i=\frac{1}{N}\sum\_{n=1}^N(x\[n\]-\bar{x})^i$ is the biased sample *i*`th` central moment, and *x̄* is the sample mean. If bias = FALSE, the calculations are corrected for bias and the value computed is the adjusted Fisher-Pearson standardized moment coefficient, i.e.

$G_1 = \frac{k_3}{k_2^{3/2}} = \frac{\sqrt{N(N-1)}}{N-2}\frac{m_3}{m_2^{3/2}}$ ## Value A polars expression ## Examples

library("polars")

df <- pl$DataFrame(x = c(1, 2, 3, 2, 1))
df$select(pl$col("x")$skew())
#> shape: (1, 1) #> ┌──────────┐ #> │ x │ #> │ --- │ #> │ f64 │ #> ╞══════════╡ #> │ 0.343622 │ #> └──────────┘