antropy.svd_entropy

antropy.svd_entropy(x, order=3, delay=1, normalize=False)[source]

Singular Value Decomposition entropy.

Parameters
xlist or np.array

One-dimensional time series of shape (n_times)

orderint

Order of SVD entropy (= length of the embedding dimension). Default is 3.

delayint

Time delay (lag). Default is 1.

normalizebool

If True, divide by log2(order!) to normalize the entropy between 0 and 1. Otherwise, return the permutation entropy in bit.

Returns
svd_efloat

SVD Entropy

Notes

SVD entropy is an indicator of the number of eigenvectors that are needed for an adequate explanation of the data set. In other words, it measures the dimensionality of the data.

The SVD entropy of a signal \(x\) is defined as:

\[H = -\sum_{i=1}^{M} \overline{\sigma}_i log_2(\overline{\sigma}_i)\]

where \(M\) is the number of singular values of the embedded matrix \(Y\) and \(\sigma_1, \sigma_2, ..., \sigma_M\) are the normalized singular values of \(Y\).

The embedded matrix \(Y\) is created by:

\[y(i)=[x_i,x_{i+\text{delay}}, ...,x_{i+(\text{order}-1) * \text{delay}}]\]
\[Y=[y(1),y(2),...,y(N-(\text{order}-1))*\text{delay})]^T\]

Examples

SVD entropy with order 2

>>> import numpy as np
>>> import antropy as ant
>>> import stochastic.processes.noise as sn
>>> x = [4, 7, 9, 10, 6, 11, 3]
>>> # Return a value in bit between 0 and log2(factorial(order))
>>> print(ant.svd_entropy(x, order=2))
0.7618909465130066

Normalized SVD entropy with order 3

>>> x = [4, 7, 9, 10, 6, 11, 3]
>>> # Return a value comprised between 0 and 1.
>>> print(ant.svd_entropy(x, order=3, normalize=True))
0.6870083043946692

Fractional Gaussian noise with H = 0.5

>>> rng = np.random.default_rng(seed=42)
>>> x = sn.FractionalGaussianNoise(hurst=0.5, rng=rng).sample(10000)
>>> print(f"{ant.svd_entropy(x, normalize=True):.4f}")
1.0000

Fractional Gaussian noise with H = 0.9

>>> rng = np.random.default_rng(seed=42)
>>> x = sn.FractionalGaussianNoise(hurst=0.9, rng=rng).sample(10000)
>>> print(f"{ant.svd_entropy(x, normalize=True):.4f}")
0.9080

Fractional Gaussian noise with H = 0.1

>>> rng = np.random.default_rng(seed=42)
>>> x = sn.FractionalGaussianNoise(hurst=0.1, rng=rng).sample(10000)
>>> print(f"{ant.svd_entropy(x, normalize=True):.4f}")
0.9637

Random

>>> rng = np.random.default_rng(seed=42)
>>> print(f"{ant.svd_entropy(rng.random(1000), normalize=True):.4f}")
0.8527

Pure sine wave

>>> x = np.sin(2 * np.pi * 1 * np.arange(3000) / 100)
>>> print(f"{ant.svd_entropy(x, normalize=True):.4f}")
0.1775

Linearly-increasing time-series

>>> x = np.arange(1000)
>>> print(f"{ant.svd_entropy(x, normalize=True):.4f}")
0.0053