When referencing this material, please include the standard citation for PhysioNet:
Goldberger AL, Amaral LAN, Glass L, Hausdorff JM, Ivanov PCh, Mark RG, Mietus JE, Moody GB, Peng CK, Stanley HE. PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals. Circulation 101(23):e215e220 [Circulation Electronic Pages; http://circ.ahajournals.org/content/101/23/e215.full]; 2000 (June 13).
Software for calculating multifractal partitions and moments of a time series is available here. To begin, download these files:
In order to to use this code correctly, it is recommended you review:
J.F. Muzy, E. Bacry and A. Arneodo. Multifractal formalism for fractal signals: The structurefunction approach versus the wavelettransform modulusmaxima method. Physical Review E 47:875884, 1993.
We also recommend the PhysioNet tutorial "A Brief Overview of Multifractal Time Series".
Requirements
 A C compiler; gcc is recommended
 awk (or gawk) pattern scanning and processing language
 make (optional but recommended)
 tar (recommended for unpacking the test files)
All of these are standard on Unix, Linux, and Mac OS X systems, and are freely available for Windows as parts of Cygwin).
Compiling
If you have a make utility, you can use it to compile and test the software, simply by typing ``make check'' (look in Makefile to see what this command does). Otherwise, compile ibs.c and link it with the C standard math library. For example, if you use the GNU C compiler (recommended), you can do this by:
gcc o multifractal O multifractal.c lm
Usage
For brief instructions about how to run the program, type its name at a command prompt:
multifractal
which should produce a message similar to:
multifractal INPUT N QMIN QMAX DW MODE >OUTPUT INPUT name of file containing the input time series N number of points (lines) in INPUT QMIN minimum MF order (moment, q) QMAX maximum MF order DW order of the Gaussian derivative wavelet (07) MODE the type of output to be produced, one of: 1: partition functions (text) 2: maxima lines (text) 3: wavelet cascade (PPM image) INPUT is a text file containing two columns of numbers; the first is ignored, and the second contains the data values.
Note that when the Hurst exponent of the input series is negative (i.e., when its DFA scaling exponent is less than 1), it is necessary to integrate the series before using it as input to this software!
Output formats
As noted above, multifractal can produce three different types of output. The output type is selected by passing 1, 2, or 3 as the sizth argument on the command line; the results of these choices are:
 1: (text, partition functions) The first column is the scale and the remaining columns give the partition functions for all MF orders in the selected range. All output values are log10transformed.
 2: (text, maxima lines) The first column is the index of the time series (time index), and the second is the scale where the maximum appears at that time. The scales are log10transformed.
 3: (PPM image, wavelet cascade) This file can be viewed using the freely available display application included in ImageMagick, as well as a variety of other image viewers.
The tau(q) and multifractal spectra of the input time series can be obtained from the partition functions (MODE 1) using mf_moments_lt.awk; see below.
Example of multifractal analysis
The input to multifractal is a text file containing two columns of numbers (time and data values).
An example multifractal time series, for which the spectrum tau(q) and the MF spectrum D(h) are analytically known, is provided in the file log_normal_sigma0.1, which can be obtained by unpacking testfiles.tar.gz:
tar xfvz testfiles.tar.gz
To generate this example time series, we used the lognormal wavelet cascade algorithm, with parameters nu = ln(2)/4 and sigma = 0.1, as described in:
First, we generate the multifractal partition function, using the command:
multifractal log_normal_sigma0.1 32768 5 5 3 1 >out.zq
where:
 log_normal_sigma0.1 is the name of the input file (text, two columns)
 32768 is the number of points (lines in the input file)
 5 specifies the minimum MF order (moment q)
 5 specifies the maximum MF order
 3 specifies that the third derivative Gaussian wavelet is to be used; values between 0 (Gaussian) and 7 (seventh derivative) are acceptable
 1 indicates that the program should produce the partition function; other legal values are 2 (produce maxima lines) and 3 (produce a PPM image of the wavelet cascade)
 out.zq is the name of the output file, to which the partition functions are to be written
Note that multifractal performs a computationally intensive process that may require a minute or more to complete, even on a fast PC. Be patient!
After obtaining the partition function (out.zq in our case), we may calculate the tau(q) spectrum and the multifractal spectrum D(h), using the awk program, mf_moments_lt.awk:
awk f mf_moments_lt.awk v a=1 v b=2.53 out.zq >out.tq
In this command, we have specified the range over which the scaling is calculated (between log10(scale)=1 and log10(scale)=2.53; the v option indicates that a parameter assigment follows, and the parameters a and b are the upper and lower limits of the scaling range). The program reads out.zq (the output that we have just obtained from multifractal), and it writes the corresponding tau(q) and D(h) curves into out.tq.
Further information
If you have questions or comments about this software, please contact the author, Yossi Ashkenazy.
If you would like help understanding, using, or downloading content, please see our Frequently Asked Questions. If you have any comments, feedback, or particular questions regarding this page, please send them to the webmaster. Comments and issues can also be raised on PhysioNet's GitHub page. Updated Tuesday, 4 October 2016 at 21:25 CEST 
PhysioNet is supported by the National Institute of General Medical Sciences (NIGMS) and the National Institute of Biomedical Imaging and Bioengineering (NIBIB) under NIH grant number 2R01GM10498709.
