# Estimating multifractal spectra with Chhabra-Jensen's method

## Multifractals

Over the last decades fractal analyses have revolutionised many fields of science. Such metrics are relevant to fields ranging from economics to neuroscience. However, some objects cannot be accurately described with a single scaling factor — fractal dimension — $$D$$ and require an infinite number of values to be accurately described .

## The multifractal spectrum

The multifractal spectum represents the Holder exponents and their Hausdorff dimensions for an object. Such spectra can be evaluated according to their geometric properties, mainly width ($$\Delta\alpha$$) and height ($$\Delta f$$) . An example of multifractal spectrum and its geometric features can be seen in figure 1. Figure 1: Example of multifractal spectrum. The figure shows the two main measures, i.e. width ($$\Delta \alpha$$) and height ($$\Delta f$$).

## The Chhabra-Jensen method

There are several different algorithms that allow the obtention of multifractal spectra from time series. The most famous are the MF-DFA , MF-DMA , and Chhabra-Jensen .

The method, amongst other advantages, allows the direct obtention of the multifractal spectra without the use of a Legendre’s transform . The spectra are obtained directly from the two parametric equations (1) and (2).

$\begin{equation} \alpha(q) = \lim_{l\rightarrow0}\frac{\sum_{i}{\mu_{i}(q,l)\log{P_{i}(l)}}}{\log{l}} \tag{1} \end{equation}$

$\begin{equation} f(q) = \lim_{l\rightarrow0}{\frac{\sum_{i}{\mu_{i}(q,l)\log{\mu_{i}(q,l)}}}{\log{l}}} \tag{2} \end{equation}$

$\mu_{i}(q,l) = \frac{P_{i}(l)^{q}}{\sum_{j}P_{j}(l)^{q}}$

## Runing the script

The script used in can be downloaded from my Github repository and is currently available in Python and Matlab (if you would like to help the adaptation to other programming languages, please get in touch!). The script can be run as shown below:

#### Python

import chhabrajensen as chj

alpha,falpha,Dq,Rsqr_alpha,Rsqr_falpha,Rsqr_Dq,muScale,Md,Ma,Mf = chj.getSpectrum(Timeseries,qValues,scales)


#### Matlab


[alpha,falpha,Dq,Rsqr_alpha,Rsqr_falpha,Rsqr_Dq,muScale,Md,Ma,Mf] = ChhabraJensen_Yuj_w0(Timeseries,qValues,scales)


INPUT:

Timeseries, qValues, and scales are all row vectors.

This function assumes that your time series is all positive values and none of the qValues can be between 0 and 1.

OUTPUT:

alpha ($$\alpha$$) and falpha ($$f(\alpha)$$) scattered against each other give the multifractal spectrum. qValues ($$q$$) and Dq ($$D_q$$) scattered against each other give the generalised dimensions spectrum. Rsqr_alpha, Rsqr_falpha, and Rsqr_Dq are the $$R^2$$ values for each of the values in $$\alpha$$, $$f(\alpha)$$, and $$D_q$$ respectively.

For the correct obtention of multifractal spectra it is important that both qValues and scales are adequately defined.

muScale ($$\log(l)$$), Md, Ma, and Mf ($$\mu(q,l)$$) are the basic matrices from which $$\alpha$$, $$f(\alpha)$$, and $$D_q$$ can be constructed by linear regression. They are included in the output mainly for completeness.

## Defining scales range

It is essential to define the range of scales from which the multifractal spectra are obtained to avoid overfitting and inaccuracies in the curves. This can be done by studying the partition function curves and selecting adequate scales.

On a log-log plot, the curves should be linear and scales that do not follow such trend can be easily identified. Figure 2 shows an example of partition function and linear regime.

Figure 2: Partition function by (dyadic) scale - linearised by the logarithm method. The scales show show a linear progression in this plot. Any scales that do not exhibit such pattern should be removed in order to obtain accurate estimates. In this case the first, the second, and the ninth scales, indicated by the dashed lines.

## Defining $$q$$ range

It is also possible to define a family of dimensions $$D_q$$ for multifractal objects. The convergence of $$D_q$$ can provide clues on the range of $$q$$, as seen in figure 3.

$D_{q} = \frac{1}{(q-1)}\lim_{l \rightarrow 0} \frac{\log\sum_{i}P_{i}^{q}(l)}{\log l}$

Figure 3: Example of generalised dimensions $$D_q$$ spectrum. A good practice when define the range of $$q$$ values is to check hoow long it takes for the $$D_q$$ values to converge. In this case around $$q = 30$$, as shown by the dashed lines.

## Now you can perform your multifractal analyses

This was a quick guide on how to evaluate multifractal time series with the script presented at my Github repository. It is also recommended to add an extra protection against overffiting, if you are evaluating large amounts of data, by verifying the $$R^2$$, e.g. discarding values of $$\alpha$$ and $$f(\alpha)$$ which feature an $$R^2 < 0.9$$ — or any other threshold you consider adequate according to your data.