Note
Go to the end to download the full example code.
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}\)

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:

The multifractal spectrum has confidence intervals for both x- and y-axes.
pwt.spectrum.plot()

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):
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:
pwt.cumulants.find_best_range(per_moment=True)
Total running time of the script: (0 minutes 11.019 seconds)