Bootstrap-based analysis#

Bootstrapping may be used in pymultifracs to determine empirical confidence intervals for the estimates (scaling functions, exponents), as well as an automated determination of the optimal scaling range among multiple choices.

Let us first generate a Multifractal Random Walks with parameters \(H = 0.8\) and \(\lambda=\sqrt{0.05}\)

import matplotlib.pyplot as plt
import numpy as np
from pymultifracs.simul import mrw

X = mrw(shape=2**15, H=0.8, lam=np.sqrt(.05), L=2**15)
plt.plot(X)
plt.show()
02 bootstrap

Bootstrapped analysis#

Wavelet transform is performed as usual:

from pymultifracs import wavelet_analysis

WT = wavelet_analysis(X, wt_name='db3', j2=None, normalization=1)
WTpL = WT.get_leaders(p_exp=2)
# The simplest way to use bootstrapping is to include the `R` parameter in
# calling :func:`mfa`, which will perform :math:`R > 1` bootstrapping
# repetitions prior to carrying out the multifractal analysis

from pymultifracs import mfa
from pymultifracs.utils import build_q_log

scaling_ranges = [(2, 8), (3, 8)]
pwt = mfa(WTpL, scaling_ranges, weighted=None, q=build_q_log(.1, 4, 15), R=20)

Plotting bootstrapped results#

By default, when bootstrapping was applied, the plotting function display the empirical confidence intervals:

02 bootstrap

The multifractal spectrum has confidence intervals for both x- and y-axes.

pwt.spectrum.plot()
wavelet p-leader - multifractal spectrum

Choice of optimal scaling range#

In order to determine the best scaling range among multiple choices, it is possible to use a bootstrapped-based criterion (see Leonarduzzi et al., 2014):

pwt = mfa(WTpL, [(2, 8), (3, 8), (2, 7), (3, 7)], weighted=None, R=20)
<xarray.DataArray (channel: 1)> Size: 8B
array([2])
Dimensions without coordinates: channel


By default, it selects an overall best range based on the goodness of fit of exponents for all cumulants (or moments), but moment-specific optimal scales can be obtained by setting the per_moment flag:

<xarray.DataArray (m: 2, channel: 1)> Size: 16B
array([[2],
       [0]])
Coordinates:
  * m        (m) int64 16B 1 2
Dimensions without coordinates: channel


Total running time of the script: (0 minutes 11.019 seconds)

Gallery generated by Sphinx-Gallery