Katz Fractal Dimension

The Katz Fractal Dimension (KFD), from Michael Katz’s 1988 analysis of waveforms, compares the total length of the path with how far it gets from its start: a straight path covers its whole length in distance, while a rough path travels far and stays close to where it began.

The formula for the Katz Fractal Dimension starts from the length L of the path of the N log prices x, the sum of its absolute steps:

\[L = \sum_{i=1}^{N - 1} \left\lvert x_{i+1} - x_{i}\right\rvert\]

Its extent d is the largest distance of any log price from the first one, and n the number of steps:

\[d = \max\left(\left\lvert x_{i} - x_{1}\right\rvert\right)\] \[n = N - 1\]

The dimension relates the extent to the length, both measured in steps of the average size L / n:

\[\text{FD} = \frac{\log\left(n\right)}{\log\left(n\right) + \log\left(\frac{d}{L}\right)}\]

A straight path gives \(1 (d = L)\), and the dimension rises as the path folds back on itself. It is quick to calculate, but it depends on the number of observations as well as on the roughness, so compare it only between series of the same length.

The fractal dimension measures how rough a path is: how much of the plane it fills rather than how far it travels. A straight line has a dimension of 1 and a path so jagged that it fills the plane a dimension of 2; a price path lies in between. For a self-affine path the dimension is 2 - H, with H the Hurst exponent, so a random walk has a dimension of 1.5, a trending path a lower and a mean-reverting path a higher one. The measures come from the analysis of physiological signals (EEG and other waveforms) and work on the log prices of N periods. Price paths are close to random walks, so the dimensions are mostly of use to compare assets with each other or a rolling estimate over time.

Also known as: KFD, Katz dimension.

In the Finance Toolkit this is get_fractal_dimension with method="katz", the same function as Fractal Dimension.

Example · EURUSD, GCUSD, BTCUSD · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_fractal_dimension:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["EURUSD", "GCUSD", "BTCUSD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.risk.get_fractal_dimension(method="katz")

Which returns:

References

  • Paper Katz, M.J. (1988). “Fractals and the analysis of waveforms.” Computers in Biology and Medicine, 18(3), 145-156.
  • Library Referenced against antropy’s katz_fd (Katz Fractal Dimension)
Share