function skewness
skewness(
x: array,
flag?: 0 | 1,
dim?: 0 | 1,
): number

Computes the skewness of a dataset.

Measures the asymmetry of the probability distribution. Positive skew indicates a longer tail on the right, negative skew indicates a longer tail on the left. Zero skew indicates symmetric distribution.

Examples

Right-skewed data

import { assertEquals } from "jsr:@std/assert";

assertEquals(skewness([1, 2, 3, 10]), 1.0182337649086284);

Symmetric data

import { assertEquals } from "jsr:@std/assert";

assertEquals(skewness([1, 2, 3, 4, 5]), 0);

Matrix skewness

import { assertEquals } from "jsr:@std/assert";

assertEquals(skewness([[1, 2, 3], [4, 5, 6]]), [0, 0]);

Parameters

Input array or matrix

optional
flag: 0 | 1

Bias correction flag (0 for bias correction, 1 for simple calculation). Default is 1

optional
dim: 0 | 1

Dimension to compute along (0 for rows, 1 for columns). Default is 0

Return Type

number

Computed skewness values

Throws

When input is invalid

skewness(
x: matrix,
flag?: 0 | 1,
dim?: 0 | 1,
): array

Computes the skewness of a dataset.

Measures the asymmetry of the probability distribution. Positive skew indicates a longer tail on the right, negative skew indicates a longer tail on the left. Zero skew indicates symmetric distribution.

Examples

Right-skewed data

import { assertEquals } from "jsr:@std/assert";

assertEquals(skewness([1, 2, 3, 10]), 1.0182337649086284);

Symmetric data

import { assertEquals } from "jsr:@std/assert";

assertEquals(skewness([1, 2, 3, 4, 5]), 0);

Matrix skewness

import { assertEquals } from "jsr:@std/assert";

assertEquals(skewness([[1, 2, 3], [4, 5, 6]]), [0, 0]);

Parameters

Input array or matrix

optional
flag: 0 | 1

Bias correction flag (0 for bias correction, 1 for simple calculation). Default is 1

optional
dim: 0 | 1

Dimension to compute along (0 for rows, 1 for columns). Default is 0

Return Type

Computed skewness values

Throws

When input is invalid