class fathon.MFDCCA(tsVec1, tsVec2=[])

Bases: object

MultiFractal Detrended Cross-Correlation Analysis class.

  • tsVec1 (iterable) – First time series used for the analysis.
  • tsVec2 (iterable) – Second time series used for the analysis.
computeFlucVec(winSizes, qList, polOrd=1, revSeg=False)

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

  • 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).

  • 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.


Computation of the mass exponents.

Returns:Mass exponents.
Return type:numpy ndarray

Computation of the multifractal spectrum.

  • numpy ndarray – Singularity strengths.
  • numpy ndarray – Multifractal spectrum.
fitFlucVec(nStart=-999, nEnd=-999, logBase=2.718281828459045, verbose=False)

Fit of the fluctuations values.

  • 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).

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


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)
b = np.random.randn(10000)

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

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

#compute mass exponents
tau = pymfdcca.computeMassExponents()

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