antropy.hjorth_params¶
- antropy.hjorth_params(x, axis=- 1)[source]¶
Calculate Hjorth mobility and complexity on given axis.
- Parameters
- xlist or np.array
1D or N-D data.
- axisint
The axis along which to perform the computation. Default is -1 (last).
- Returns
- mobility, complexityfloat
Mobility and complexity parameters.
Notes
Hjorth Parameters are indicators of statistical properties used in signal processing in the time domain introduced by Bo Hjorth in 1970. The parameters are activity, mobility, and complexity. EntroPy only returns the mobility and complexity parameters, since activity is simply the variance of \(x\), which can be computed easily with
numpy.var()
.The mobility parameter represents the mean frequency or the proportion of standard deviation of the power spectrum. This is defined as the square root of variance of the first derivative of \(x\) divided by the variance of \(x\).
The complexity gives an estimate of the bandwidth of the signal, which indicates the similarity of the shape of the signal to a pure sine wave (where the value converges to 1). Complexity is defined as the ratio of the mobility of the first derivative of \(x\) to the mobility of \(x\).
References
Examples
Hjorth parameters of a pure sine
>>> import numpy as np >>> import antropy as ant >>> sf, f, dur = 100, 1, 4 >>> N = sf * dur # Total number of discrete samples >>> t = np.arange(N) / sf # Time vector >>> x = np.sin(2 * np.pi * f * t) >>> np.round(ant.hjorth_params(x), 4) array([0.0627, 1.005 ])
Random 2D data
>>> np.random.seed(42) >>> x = np.random.normal(size=(4, 3000)) >>> mob, com = ant.hjorth_params(x) >>> print(mob) [1.42145064 1.4339572 1.42186993 1.40587512]
>>> print(com) [1.21877527 1.21092261 1.217278 1.22623163]
Fractional Gaussian noise with H = 0.5
>>> import stochastic.processes.noise as sn >>> rng = np.random.default_rng(seed=42) >>> x = sn.FractionalGaussianNoise(hurst=0.5, rng=rng).sample(10000) >>> np.round(ant.hjorth_params(x), 4) array([1.4073, 1.2283])
Fractional Gaussian noise with H = 0.9
>>> rng = np.random.default_rng(seed=42) >>> x = sn.FractionalGaussianNoise(hurst=0.9, rng=rng).sample(10000) >>> np.round(ant.hjorth_params(x), 4) array([0.8395, 1.9143])
Fractional Gaussian noise with H = 0.1
>>> rng = np.random.default_rng(seed=42) >>> x = sn.FractionalGaussianNoise(hurst=0.1, rng=rng).sample(10000) >>> np.round(ant.hjorth_params(x), 4) array([1.6917, 1.0717])