function jbtest
jbtest(x: array): number

Performs the Jarque-Bera test for normality.

Tests the null hypothesis that the input data follows a normal distribution with an unknown mean and variance. The test statistic combines skewness and excess kurtosis.

Examples

Example 1

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

const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039];

Compute the Jarque-Bera test statistic for normality

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

const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039];

assertEquals(jbtest(x), 0.6360604293924916);

Compute JB test statistic for a dataset with more variation

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

assertEquals(jbtest([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 0.6244872972145701);

JB test on a perfectly normal dataset (should be close to 0)

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

assertEquals(jbtest([0, 0, 0, 0, 0]), NaN);

Test with a highly skewed dataset

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

assertEquals(jbtest([1, 1, 1, 1, 100]), 1.888020833333333);

Parameters

The dataset (array of values).

Return Type

number

The Jarque-Bera test statistic.

Throws

If the input is not an array or is empty.