MFDFA

class fathon.MFDFA(tsVec)

Bases: object

MultiFractal Detrended Fluctuation Analysis class.

Parameters:

tsVec (iterable) – Time series used for the analysis.

computeFlucVec(winSizes, qList, polOrd=1, revSeg=False)

Computation of the fluctuations in each window for each q-order.

Parameters:
  • winSizes (numpy ndarray) – Array of window’s sizes.

  • qList (float or iterable or numpy ndarray) – List of q-orders used to compute F.

  • polOrd (int, optional) – Order of the polynomial to be fitted in each window (default : 1).

  • revSeg (bool, optional) – If True, the computation of F is repeated starting from the end of the time series (default : False).

Returns:

  • numpy ndarray – Array n of window’s sizes.

  • numpy ndarray – qxn array F containing the values of the fluctuations in each window for each q-order.

computeMassExponents()

Computation of the mass exponents.

Returns:

Mass exponents.

Return type:

numpy ndarray

computeMultifractalSpectrum()

Computation of the multifractal spectrum.

Returns:

  • numpy ndarray – Singularity strengths.

  • numpy ndarray – Multifractal spectrum.

fitFlucVec(nStart=-999, nEnd=-999, logBase=2.718281828459045, verbose=False)

Fit of the fluctuations values.

Parameters:
  • nStart (int, optional) – Size of the smaller window used to fit F at each q-order (default : first value of n).

  • nEnd (int, optional) – Size of the bigger window used to fit F at each q-order (default : last value of n).

  • logBase (float, optional) – Base of the logarithm for the log-log fit of n vs F (default : e).

  • verbose (bool, optional) – Verbosity (default : False).

Returns:

  • numpy ndarray – Slope of the fit for each q-order.

  • numpy ndarray – Intercept of the fit for each q-order.

saveObject(outFileName)

Save current object state to binary file.

Parameters:

outFileName (str) – Output binary file. .fathon extension will be appended to the file name.

Usage examples

import numpy as np
import fathon
from fathon import fathonUtils as fu

#time series
a = np.random.randn(10000)

#zero-mean cumulative sum
a = fu.toAggregated(a)

#initialize mfdfa object
pymfdfa = fathon.MFDFA(a)
#compute fluctuation function and generalized Hurst exponents
wins = fu.linRangeByStep(10, 2000)
n, F = pymfdfa.computeFlucVec(wins, np.arange(-3, 4, 0.1), revSeg=True, polOrd=1)
list_H, list_H_intercept = pymfdfa.fitFlucVec()

#compute mass exponents
tau = pymfdfa.computeMassExponents()

#compute multifractal spectrum
alpha, mfSpect = pymfdfa.computeMultifractalSpectrum()