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

Hurst index/exponent.

It's a useful statistic for detecting if a time series is mean reverting (anti-persistent), totally random or persistent. A value in the range [0.5) indicates mean-reverting (anti-persistent) A value of 0.5 indicate a random walk A value H in the range (0.5,1] indicates momentum (persistent)

Examples

Hurst exponent for a single time series

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(hurst(x), 0.3440590389509703);

Hurst exponent for different data

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

assertEquals(hurst([0.05, 0.03, 0.08, -0.02]), 0.19397632085813782);

Hurst exponent interpretation (0.5 = random walk)

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

assertEquals(hurst([0.01, 0.02, -0.01, 0.03, -0.02]), 0.1405484063287468);

Parameters

array of values

optional
flag: 0 | 1

normalization value 0: population, 1:sample (def: 1)

optional
dim: 0 | 1

dimension 0: row, 1: column (def: 0)

Return Type

number

Hurst exponent

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

Hurst index/exponent.

It's a useful statistic for detecting if a time series is mean reverting (anti-persistent), totally random or persistent. A value in the range [0.5) indicates mean-reverting (anti-persistent) A value of 0.5 indicate a random walk A value H in the range (0.5,1] indicates momentum (persistent)

Examples

Hurst exponent for a single time series

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(hurst(x), 0.3440590389509703);

Hurst exponent for different data

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

assertEquals(hurst([0.05, 0.03, 0.08, -0.02]), 0.19397632085813782);

Hurst exponent interpretation (0.5 = random walk)

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

assertEquals(hurst([0.01, 0.02, -0.01, 0.03, -0.02]), 0.1405484063287468);

Parameters

array of values

optional
flag: 0 | 1

normalization value 0: population, 1:sample (def: 1)

optional
dim: 0 | 1

dimension 0: row, 1: column (def: 0)

Return Type

Hurst exponent