Petrosian Fractal Dimension
The Petrosian Fractal Dimension (PFD), from Arthur Petrosian’s 1995 work on EEG recordings, measures roughness by how often the path changes direction: it reduces the series to the signs of its changes and counts how often the sign flips.
The formula for the Petrosian Fractal Dimension takes the number of log prices N and the number of sign changes \(N_{\delta}\) of the returns, the changes between consecutive log prices:
\[\text{FD} = \frac{\log\left(N\right)}{\log\left(N\right) + \log\left(\frac{N}{N + 0.4 \cdot N_{\delta}}\right)}\]A path that never turns gives 1, and the dimension rises with the number of turns. It looks only at the direction of the moves, not their size, so it is the coarsest measure of roughness.
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: PFD, Petrosian dimension.
In the Finance Toolkit this is get_fractal_dimension with method="petrosian", 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="petrosian")
| Parameter | Type | Description | Example |
|---|---|---|---|
method | str | The fractal dimension. Options are: “higuchi” (Higuchi Fractal Dimension), “katz” (Katz Fractal Dimension), “petrosian” (Petrosian Fractal Dimension). Defaults to “higuchi”. | "higuchi" |
period | str | None | The data frequency. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to None, which uses “daily”. | "weekly" |
rolling | int | None | The number of periods of a rolling window, at least kmax + 2 for “higuchi” (12 by default) and 3 for the others. Defaults to None, which calculates one value over the full history of every asset. | 4 |
kmax | int | The largest step k of the Higuchi dimension. Defaults to 10. | 10 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
Which returns:
| Item | 0 |
|---|---|
| EURUSD | 1.0259 |
| GCUSD | 1.0269 |
| BTCUSD | 1.0264 |
| Benchmark | 1.0257 |
4 rows
References
- Paper Petrosian, A. (1995). “Kolmogorov complexity of finite sequences and recognition of different preictal EEG patterns.” Proceedings of the Eighth IEEE Symposium on Computer-Based Medical Systems, 212-217.
- Library Referenced against antropy’s petrosian_fd (Petrosian Fractal Dimension)