apollon.fractal module

apollon/fractal.py

Tools for estimating fractal dimensions.

Function:
corr_dim Estimate correlation dimension. embdedding Pseudo-phase space embdedding. lorenz_attractor Simulate Lorenz system. pps_entropy Entropy of pps embdedding.
apollon.fractal.correlation_dimension(data, tau, m, r, mode='cut', fit_n_points=10)

Compute an estimate of the correlation dimension D_2.

Parameters:
  • data (1d array) –
  • tau (int) –
  • m (iterable) –
  • r (iterable) –
  • mode (str) –
Returns:

lCrm (array) Logarithm of correlation sums given r_i. lr (array) Logarithm of radii. d2 (float) Estimate of correlation dimension.

apollon.fractal.embedding(inp_sig, tau, m=2, mode='zero')

Generate n-dimensional pseudo-phase space embedding.

Params:

inp_sig (iterable) Input signal. tau (int) Time shift. m (int) Embedding dimensions. mode (str) Either zero for zero padding,

wrap for wrapping the signal around, or cut, which cuts the signal at the edges.
Note: In cut-mode, each dimension is only
len(sig) - tau * (m - 1) samples long.
Returns:
(np.ndarray) of shape
(m, len(inp_sig)) in modes ‘wrap’ or ‘zeros’, or (m, len(sig) - tau * (m - 1)) in cut-mode.
apollon.fractal.embedding_entropy(emb, bins, extent=(-1, 1))

Calculate entropy of given embedding unsing log_e.

Parameters:
  • emb (ndarray) –
  • bins (int) –
  • extent (tuple) –
Returns:

(float) Entropy of pps.

apollon.fractal.lorenz_attractor(n, sigma=10, rho=28, beta=2.6666666666666665, init_xyz=(0.0, 1.0, 1.05), dt=0.01)

Simulate a Lorenz system with given parameters.

Params:
n (int) Number of data points to generate. sigma (float) System parameter. rho (rho) System parameter. beta (beta) System parameter. init_xyz (tuple) Initial System state. dt (float) Step size.
Returns:xyz (array) System states.