Hjorth Parameters
Calculate the Hjorth parameters of a series, by default the returns: its Activity, Mobility and Complexity, and the number of times it crosses zero, over the full history or a rolling window.
The Activity is the variance. The Mobility, the standard deviation of the changes relative to that of the series, is a mean frequency: it is about Sqrt(2) = 1.41 for independent returns, lower when returns persist and higher when they alternate. The Complexity compares the Mobility of the changes with that of the series and grows as the series looks less like a single smooth wave. The Zero Crossings count how often the returns change sign.
The formula is as follows:
\[\text{Activity} = \operatorname{Var}(x)\] \[\text{Mobility} = \operatorname{Sqrt}\left(\frac{\operatorname{Var}(\,\mathrm{d}x)}{\operatorname{Var}(x)}\right)\] \[\text{Complexity} = \frac{\operatorname{Sqrt}\left(\frac{\operatorname{Var}(\text{d2x})}{\operatorname{Var}(\,\mathrm{d}x)}\right)}{\text{Mobility}}\] \[\text{Zero Crossings} = \text{the number of sign changes of}\; x,\;\; \text{values of exactly 0 skipped}\]with dx the first and d2x the second differences and Var the sample variance (ddof=1).
Also known as: Hjorth activity, Hjorth mobility, Hjorth complexity, zero-crossing rate.
Example · AAPL, MSFT, NVDA · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_hjorth_parameters:
from financetoolkit import Toolkit
toolkit = Toolkit(
tickers=["AAPL", "MSFT", "NVDA"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_hjorth_parameters()
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
What were the Hjorth activity, mobility and complexity of the daily returns of Apple, Microsoft and Nvidia from 2021 to 2025?
Which returns:
| Item | Activity | Mobility | Complexity | Zero Crossings |
|---|---|---|---|---|
| AAPL | 0.0003 | 1.4058 | 1.2280 | 611 |
| MSFT | 0.0003 | 1.4267 | 1.2057 | 625 |
| NVDA | 0.0011 | 1.4485 | 1.2097 | 619 |
3 rows
Using Your Own Data
get_hjorth_parameters runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:
from financetoolkit import Economics, Econometrics
economics = Economics(start_date="2000-01-01")
unemployment = economics.get_unemployment_rate(
countries=["United States", "Germany"], period="monthly"
)
econometrics = Econometrics(data=unemployment, changes="difference")
econometrics.get_hjorth_parameters()
Parameters
get_hjorth_parameters accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | None | The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to None, which uses “daily”. | "weekly" |
column | str | The historical data column the parameters are calculated on: “Return” for the returns (the changes of the series), “Adj Close” for the prices (the series as given with Econometrics(data=...)) or “Close” for the traded prices. Defaults to “Return”. | "Return" |
rolling | int | None | The number of periods of a rolling window, at least 4. Defaults to None, which calculates the parameters over the full history of every asset. | 4 |
include_benchmark | bool | Whether to include “Benchmark” among the assets. Defaults to False. | True |
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 |
References
- Paper Hjorth, B. (1970). “EEG analysis based on time domain properties.” Electroencephalography and Clinical Neurophysiology, 29(3), 306-310.
- Library Referenced against antropy’s hjorth_params
- Library Referenced against antropy’s num_zerocross