You are on page 1of 14

Physica A 392 (2013) 89102

Contents lists available at SciVerse ScienceDirect


Physica A
journal homepage: www.elsevier.com/locate/physa
Real-time fractal signal processing in the time domain
Andrs Hartmann
a
, Pter Mukli
a,1
, Zoltn Nagy
a,1
, Lszl Kocsis
a
, Pter Hermn
a,b
,
Andrs Eke
a,
a
Institute of Human Physiology and Clinical Experimental Research, Faculty of Medicine, Semmelweis University, Budapest, Hungary
b
Department of Diagnostic Radiology, Yale University, New Haven, CT, USA
a r t i c l e i n f o
Article history:
Received 29 January 2010
Received in revised form 8 June 2012
Available online 11 August 2012
Keywords:
Fractal
Time series
Real-time analysis
DFA
SSC
Software
a b s t r a c t
Fractal analysis has proven useful for the quantitative characterization of complex time
series by scale-free statistical measures in various applications. The analysis has commonly
been done offline with the signal being resident in memory in full length, and the
processing carried out in several distinct passes. However, in many relevant applications,
such as monitoring or forecasting, algorithms are needed to capture changes in the fractal
measure real-time. Here we introduce real-time variants of the Detrended Fluctuation
Analysis (DFA) and the closely related Signal Summation Conversion (SSC) methods,
which are suitable to estimate the fractal exponent in one pass. Compared to offline
algorithms, the precision is the same, the memory requirement is significantly lower, and
the execution time depends on the same factors but with different rates. Our tests show
that dynamic changes in the fractal parameter can be efficiently detected. We demonstrate
the applicability of our real-time methods on signals of cerebral hemodynamics acquired
during open-heart surgery.
2012 Published by Elsevier B.V.
1. Introduction
Ever since Mandelbrot and Van Ness [1] introduced the dichotomous model of fractional Gaussian noise and fractional
Brownian motion (fGn and fBm, respectively) and later Mandelbrot [2] powerfully demonstrated the ubiquitous presence
of scale-free structures and processes in nature, the concept of fractal analysis and the interpretation of this aspect
of characterizing systems complexity has advanced considerably. The idea of fractal analysis proved to be useful in
the analyses of physical [35], computer networking [6,7], geological [8,9], economical [10,11], psychological [12,13],
physiological [1416] time series data, and in clinically relevant applications too [1719].
Fractal time series analysis in the time domain has typically been done offline. In these implementations the signal has to
remain available in full length and processed in multiple passes to yield a statistical measure for each and every scale. This
strategy, however, becomes an obstacle in real-time applications, such as monitoring or forecasting, where the purpose of
the application of fractal time series analysis should be a prompt assessment of a condition when the local fractal descriptor
of temporal complexity changes due to concomitant alterations in the underlying system dynamics.
Owing to its independence from signal class and its apparent robustness [2023], the DFA method has become a
frequently used tool for time domain fractal analysis. Its unique advantage is that its precision is moderately affected by
signal length [21], therefore it can be used on short time series [23,24]. DFA is closely related to the Scaled Windowed

Correspondence to: Institute of Human Physiology and Clinical Experimental Research, Faculty of Medicine, Semmelweis University, Tzolt Street
37-47, P.O.B. 448, Budapest, 1446, Hungary. Tel.: +36 20 462 9063; fax: +36 13343162.
E-mail address: eke.andras@med.semmelweis-univ.hu (A. Eke).
1
Equally contributing authors.
0378-4371/$ see front matter 2012 Published by Elsevier B.V.
doi:10.1016/j.physa.2012.08.002
90 A. Hartmann et al. / Physica A 392 (2013) 89102
Nomenclature
Symbols and definitions
DFA Detrended Fluctuation Analysis, DFA for short
SSC Signal Summation Conversion method, SSC for short
ldDFA Line-detrended Detrended Fluctuation Analysis
bdSSC Bridge-detrended Signal Summation Conversion method
N Length of time series
X
i
Time series (signal for short), where i = 1, . . . , N
Y
i
Time series (obtained by cumulative summation of signal X
i
), where i = 1, . . . , N
n Window size of detrending
X

i,n
Detrended time series (detrended signal for short)
W Number of different window sizes used
M Sliding window size for real-time methods, M N, which thus defines the largest time scale of the fractal
analysis
fGn Fractional Gaussian noise, a stationary signal with fractal autocorrelation structure
fBm Fractional Brownian motion, a non-stationary signal with self-similar (fractal) structuring
H Hurst exponent
H
true
The value of the Hurst exponent at which the time series was generated

H Estimated value of the Hurst exponent

H
SSC
Estimated value of the Hurst exponent using SSC method, where for fGn 0 <

H
SSC
< 1, for fBm1 <

H
SSC
< 2.
This will be referred to as extended, which allows a direct comparison to of DFA.
Estimated value of the fractal parameter using DFA method, for an fGn signal =

H and for an fBm signal
=

H + 1
Variance (SWV) method introduced by Mandelbrot and van Ness [1] from which Eke et al. [15] designed the SSC method
specifically for a reliable signal classification based on the dichotomy of the fGn/fBm model of Mandelbrot and Van Ness [1]
which implies improved performance in estimating H too (see Fig.16 in the reference) [21]. There are other candidates
similar to DFA to consider like the DMA (Detrended Moving Average) algorithm [25]. Several modifications of DFA
have been developed in various fields [2630] for detecting temporal variations in fractal descriptors. However these
implementations cannot be regarded as optimized because one data point is dealt with in multiple passes, significantly
increasing computational cost. Changing complexity reflected in a fractal measure of time series showing rapid dynamics
canbe quantifiedinreal-time withanefficient algorithm. Apromising attempt inthe directionof using anefficient algorithm
is the application of incremental discrete wavelet transform for multifractals reported by Brodu [31].
Therefore, the aims of this study were: (i) to develop software tools optimized for real-time analysis of fractality in the
time domain (ii) to evaluate their performance in numerical experiments regarding precision, numerical stability, execution
time, dynamic behavior, and (iii) to demonstrate their applicability. First, we briefly overview the offline algorithms of
DFA [32] and SSC [15] methods, then introduce their real-time algorithms followed by the description of our strategy of
performance analysis along with results of numerical experiments, and that of characterization of precision and limitations
of the methods. Applicability is demonstrated by analyzing a time series recorded in a medical environment, where fast
processing is a basic requirement.
2. Methods
2.1. Offline analysis
DFA and SSC have a similar algorithmic design in that both yield an estimate of the scaling exponent by relying on similar
statistical descriptors. The block-diagram of the original algorithms [15,32] is shown in the left panel of Fig. 1.
The fact that the time series must be resident in full length while the loop for different window sizes is executed renders
this type of analysis offline.
2.1.1. Detrending
Detrending removes a fitted polynomial trend fromthe sample [22,33,34]. Here we focus on the most common first order
(linear) method of detrending:
f
i
= m i + b
X
i
= X

i
f
i
(1)
A. Hartmann et al. / Physica A 392 (2013) 89102 91
where m is the slope and b is the intercept of the trend line in the ith window, f
i
. It has two subtypes: the bridge and the
line detrending. The former fits a line across the first and the last data point of the window, while the latter subtracts the
least squares fitted regression line. Accordingly, for a sample with window length n the parameters of the bridge and line
detrending are shown in Eqs. (2) and (3).
m
bd
=
X
1
X
n
n 1
b
bd
= X
1
m
bd
(2)
m
ld
=
n
n

i=1
X
i
i
n

i=1
X
i

n

i=1
i
n
n

i=1
i
2

_
n

i=1
i
_
2
b
ld
=
n

i=1
X
i
m
ld

n

i=1
i
n
(3)
where bd and ld refer to bridge and line detrending, respectively.
2.1.2. SSC
The SSC method uses SD
n
, the standard deviation for window size n, as the measure of the fluctuation:
SD
n
=

_
1
n

n

i=1
_
Y

i,n


Y

i,n
_
2
, (4)
where Y
i
denotes cumulative summation of X
i
, and

Y

i,n
the mean after detrending. For fractal signals, SD
n
depends on the
window size in a power law fashion:
SD
n
=
d
p n

H
SSC
, (5)
where p is a suitable factor of proportionality, =
d
stands for equality in distribution and

H
SSC
is the fractal exponent. By
taking the logarithm of Eq. (5) the following practical formula can be obtained:
log(SD
n
) =
d
log(p) +

H
SSC
log(n), (6)
which is in fact the equation of the fitted regression line with

H
SSC
as its slope.
2.1.3. DFA
By the same token, DFA can be introduced using F
n
, a measure of the root-mean-square fluctuation:
F
n
=

_
1
n

n

i=1
Y
2
i,n
(7)
F
n
=
d
p n

(8)
log(F
n
) =
d
log(p) + log(n). (9)
In this case, the slope of the regression line yields the estimate of . Eqs. (4) and (7) clearly demonstrate that SSC and
DFA only differ in subtracting the mean after detrending from the scale-free statistical measure of the signal.
Originally, DFA was designed with line detrending [32], while SWV performed better using bridge detrending [35]. The
correspondences between

H, the estimate of the Hurst exponent assessed by SSC and the fractal estimate, , obtained by
DFA is

H
SSC
=

H, =

H if X
i
is an fGn signal;

H
SSC
=

H + 1, =

H + 1 if X
i
is an fBm signal [21,32]. To handle fractal
estimates in a consistent manner, in the next sections we convert all estimates to extended Hurst exponent.
2.2. Real-time analysis
Contrary tooffline methods, whichrunthroughthe time series at least once for any givenwindowsize inorder toestimate
the statistical measure, real-time analysis accumulates all the data needed for detrending and compute the statistical
measure in one-pass as captured in the flowchart of Fig. 1 (right panel).
92 A. Hartmann et al. / Physica A 392 (2013) 89102
Fig. 1. Flowcharts of the offline (left) and real-time (right) implementations of the DFA algorithmof Peng et al. [32] and the SSC algorithmof Eke et al. [15].
On the left, * refers to specific steps of DFA where substitution by SD
n
for F
n
yields SSC. On the right, a case of N = M is shown. Calculations performed in
subprocedures are as follows: updateSums updates the corresponding sums according to the actual value fromthe input, and calculateMeasure returns the
averaged measure for all windowsizes. The difference between offline and real-time implementations of these algorithms is that while the former executes
all steps of calculations to yield H for each window sizes separately, our real-time algorithm calculates H from sums (sx, sx
2
, sxi, sy, sy
2
, syi) calculated
and accumulated upon filling each window thus allowing handling each data point in a one-pass manner.
2.2.1. Strategy of real-time signal processing
Our real-time analysis employs a sliding window approach as seen schematically in Fig. 2. A cascade of dyadically sized
analyzing windows is created within the sliding window. In the initial phase of the analysis, windows are being filled with
progressing time until at t
init
= M t, all windows will have been initialized. The first estimate is computed at t
init
, when
M data points have already been processed. The range of window sizes representing the time scales of the analysis used
in fitting for the regression slope are determined by minimizing the mean squared error (MSE) of fitting as the largest
and smallest window sizes are discarded according to Peng et al. [32] and Cannon et al. [35] (see shaded areas in Fig. 2).
To keep up with the progressing analysis, a set of index variables (for raw signal: index1, for summed signal: index2) are
defined pointing to the actual window. Offset (for raw signal: offset1, for summed signal: offset2) variables point to the
data under processing relative to index for each analyzing window, respectively. Helper variables (defined as: sx =

n
i=1
X
i
,
sx
2
=

n
i=1
X
2
i
, sxi =

n
i=1
X
i
i and sy =

n
i=1
Y
i
, sy
2
=

n
i=1
Y
2
i
, syi =

n
i=1
Y
i
i) are calculated for the raw and summed
A. Hartmann et al. / Physica A 392 (2013) 89102 93
Fig. 2. Strategy of real-time signal processing. A set of sliding memory slots is being reserved representing the dyadic windowsizes. Each windowis filled
with values of the time series (shown on top) in the sequence shown in the lower panel. Once a given window is passed, the values of helper variables sx,
sx
2
, sxi, sy, sy
2
, syi are stored in the corresponding slot. This strategy allows for a one-pass handling of data points and is thus the very basis of our real-time
implementation of DFA and SSC algorithms. Once the window size M is reached, an estimate of H is obtained from the helper variables first at t
init
, than
via elongation at subsequent times, t
H
i
. Index points to the actual windows, offset points to the data under processing relative to index. Note that shaded
windows are discarded as recommended by Peng et al. [32] and Cannon et al. [35].
signal, respectively, in order to make them available for calculating H once all the window has been filled and processed at
time t
H
i
. Subsequently, the elongation is circular (the last window of any size is followed by the first one).
2.2.2. Real-time detrending
With the following considerations, m and b parameters of the trend line can be calculated in real-time as well.
For bridge detrending, we can compute these values by retrieving Y
i
, the first value of the window when Y
n
arrives and
then simply proceed with detrending, using Eq. (2). Quite fortunately, to perform line detrending in one pass, we can use
the accumulated values sy, sy
2
and syi to calculate the measures SD
n
or F
n
according to Eqs. (13) and (15). The equation of
the fitted line is derived from Eq. (3) and can be simply expressed as
m
ld
=
6
_
2
n

i=1
i Y
i
+ (n + 1)
n

i=1
Y
i
_
n (n
2
1)
b
ld
=
n

i=1
Y
i
n

m
ld
(n + 1)
2
.
(10)
2.2.3. Derivation of the measures
By writing standard deviation of a time series X
i
in the form
SD
n
=

_
1
n

n

i=1
Y
2
i,n

1
n
2
_
n

i=1
Y

i,n
_
2
, (11)
we can compute SD
n
by accumulating Y
i
and Y
i
2
values for i = 1, . . . , n. The method is also known as the textbook one-pass
method for calculating SD [36]. According to the fitted line equation, the standard deviation for the detrended SSC method
can be written as
SD
n
=

_
1
n

n

i=1
(Y
i
m i b)
1
n
2

_
n

i=1
(Y
i
m i b)
_
2
. (12)
94 A. Hartmann et al. / Physica A 392 (2013) 89102
Table 1
Memory usage. Types are referred to by their common names with their C data type in parentheses. Size of the types is given
for 32 byte Intel architecture. Besides the sums, index and offset variables were introduced for each window size to follow
the progress of data processing as required by the appropriate analysis.
Name Count Type Size of type (byte) Total size (byte)
sx W Floating point (double) 8 8 W
sx
2
W Floating point (double) 8 8 W
sxi W Floating point (double) 8 8 W
sy W Floating point (double) 8 8 W
sy
2
W Floating point (double) 8 8 W
syi W Floating point (double) 8 8 W
Index1 W Integer (unsigned) 4 4 W
Offset1 W Integer (unsigned) 4 4 W
Index2 W Integer (unsigned) 4 4 W
Offset2 W Integer (unsigned) 4 4 W
Total W 64 64 W
Both the first and second summation can be expressed with helper variables sy, sy
2
, syi; only using m, b, n and constants as
factors given by Eq. (10). Note, that here we only use the parameter m from the trend line, while b is not present in the final
form of the equation at all. The final formula for SSC is then
SD
n
=

_
m
2

n
2
1
12
+
1
n

n

i=1
_
Y
2
i
2 m Y
i
i + m (n + 1) Y
i
_

1
n
2

_
n

i=1
Y
i
_
2
. (13)
A similar transformation can be done to the corresponding equation of DFA,
F
n
=

_
1
n

n

i=1
(Y
i
m i b)
2
. (14)
The resulting real-time formula is given by Eq. (15)
F
n
=

_
m
2
n
2
3
+
m
2
n
2
+
m
2
6
+ m b n + m b + b
2
+
1
n

n

i=1
(Y
2
i
2m Y
i
i 2b Y
i
). (15)
2.2.4. Memory usage
The real-time analysis deals with memory in a very efficient manner given the size of memory needed is O(W), therefore
it is independent from signal length, N. Consider a time series of length N = 2
17
, using bdSSC on an fBm signal and window
sizes chosen for W = 6. The memory required by the real-time algorithm is 2 6 32 = 384 bytes, while the corresponding
offline analysis would require at least 2 q 2
17
= 2 q 131072 bytes, where the input data is represented in q bytes. The
factor of 2 accounts for the parallel calculations on raw and summed signal. A detailed inventory of memory usage for the
real-time algorithms can be found in Table 1.
2.3. Characterization of the methods
The fractal analytical methods ought to be tested on synthesized fractal signals in numerical experiments, as described
earlier [14,15,2022,35,37]. Strategies for numerical testing of fractal tools, such as DFA and SSC, on synthetic fractal time
series, as usedinthis study, have beendescribedindetail by Eke et al. elsewhere [15,21]. Inthis study, numerical experiments
were done systematically for all the methods, on both fGn and fBm signals. All time series were generated by the method of
Davies and Harte (DHM) [38] because this yields stochastic time series with exact fractal autocorrelation structuring. fBm
signals had to be obtained by cumulatively summing fGn signals with a targeted value of H
true
.
2.3.1. Execution time
The execution times of the different algorithms were determined in numerical tests. To ensure their adequate precision,
1000 realizations were made for each test. The obtained values of execution times were expressed in milliseconds. Besides
the essential, no other processes or services were running. For real-time methods, the signal length was equal to the length
of the analyzing window (N = M).
A. Hartmann et al. / Physica A 392 (2013) 89102 95
Table 2
Runtime of methods expressed in ms, averaged for 1000 runs as shown in the first column under each method.
For determining runtime we used M = N for each signal length. The last two columns show window sizes used for
fitting the regression lines in order to determine F
n
and SD
n
at minimal MSE. The format is: smallest used window
largest used window (number of window sizes). To estimate smallest and largest window sizes, we generated 100 time
series on every signal length for each H
true
= 0.1, 0.2, . . . , 0.9. Values in the table stand for the exponents of 2.
N Offline Real-time Window sizes
bdSSC ldDFA bdSSC ldDFA bdSSC ldDFA
2
8
0.32 0.48 0.17 0.18 27(6) 27(6)
2
9
0.59 1.04 0.26 0.38 37(5) 28(7)
2
10
1.16 1.73 0.47 0.46 37(5) 37(5)
2
11
2.45 3.82 1.02 1.07 38(6) 38(6)
2
12
4.59 7.62 1.86 2.16 37(5) 38(6)
2
13
8.57 15.26 2.64 4.16 47(4) 38(6)
2
14
26.72 27.7 9.71 9.07 48(5) 48(5)
2
15
56.94 89.67 20.91 21.01 49(6) 49(6)
2
16
114.64 197.16 42.29 50.06 49(6) 410(7)
2
17
243.3 396.71 95.85 103.4 410(7) 410(7)
2.3.2. Numerical stability
Although the way Eqs. (13) and (15) were developed from Eqs. (11) and (14) is mathematically correct, it can still lead
to small round-off errors due to the underlying representation of floating-point numbers [39], which can accumulate rather
than being suppressed in time. The phenomenon is known as numerical instability, and can produce catastrophic results by
marring the output with errors expanding from the least significant bit (invalidating or deleting bits).
The numerical stability was tested by the method of Kahan and Darcy [40], applying directed rounding modes of floating-
point arithmetic to determine if a given algorithm is stable or not. Knowing that deletion of bits occurs when summing
numbers with significant differences in magnitude [36,40], we tested time series of different combinations of mean and
SD. The stability was then expressed as the function of Coefficient of Variation, (CV = SD/mean), and limitations of CV to
consider were determined in order to keep the algorithms stable.
In case of an fGn signal, CV is constant due to its stationarity, therefore only when its level is low will lead to numerical
instability (small round-off errors, i.e.). In case of a persistent fBm signal owing to its persistency, CV may vary with time,
whichalso leads to numerical instability. This is one of the reasons why signal classificationis a critical issue inthe estimation
of H.
2.3.3. Real-time signal classification
Signal classification was carried out in real-time by comparing estimated Hurst exponents (

H) yielded from raw and


summed signals. Taking the summed signal, condition of < 1 and

H
SSC
< 1 identifies an fGn while > 1 and

H
SSC
> 1
identifies an fBm signal (

H
SSC
= ). In case of fBm the estimate from the raw signal (for case of fGn) is used with its value
increased by one.
2.3.4. Precision
Given the results of the analysis depends on the windowsizes used in fitting for the regression slope [35], an optimization
based on MSE of the fitting for each method and signal length improved precision (see Table 2 for the used set of analyzing
window sizes).
According to an approach used earlier in defining precision of fractal estimates [21], for the cases of N = M, 2
8
M
2
14
, 0 < H
true
< 2 the percent fraction of

H
s
were determined for the targeted precision of |H
true


H
real-time
| < 0.05 or
|H
true


H
real-time
| < 0.2.
2.3.5. Dynamic behavior
In order to test the response to abrupt changes in H, fGn test time series were concatenated from two signals generated
at different H
true
, this way effectively creating a step function in H. The dynamic behavior of our real-time analysis has been
tested on downward and upward steps in H function.
2.3.6. In vivo application
Our real-time algorithms were tested on signals acquired during open-heart surgery in the Department of Cardiac
Surgery, Semmelweis University, Budapest, Hungary. For this purpose, total hemoglobin concentration signal was obtained
non-invasively from the prefrontal brain cortex of an anesthetized patient by a near-infrared (NIR) imager developed by
Prof. Britton Chance (University of Pennsylvania, Philadelphia, PA, USA) [41]. Total hemoglobin concentration changes in the
prefrontal cortex were calculated based on the modified BeerLambert law [42], and the analyses were carried out offline
on one selected channel corresponding to a given cortical region. The Regional Committee of Science and Research Ethics
of the Semmelweis University approved these human experiments. The near infrared spectroscopic (NIRS) measurements
96 A. Hartmann et al. / Physica A 392 (2013) 89102
fully complied with the established protocols of cardiopulmonary bypass surgery and were carried out after obtaining a
written consent from the patient.
2.4. Development and testing environment
The algorithms were implemented under GNU Linux in C/C++, and compiled with gcc/g++. The tests were run on a
Knoppix 4.3 cluster of 3 PCs, except the tests for execution time, which were run on a single Intel Pentium M processor
1.73 GHz. To obtain the source code for free under the open source GPL license contact the authors via e-mail.
3. Results
3.1. Execution time
Execution times were found to be a linear function of window sizes used (and signal length due to N = M); moreover,
they were similar for the different methods up to a constant factor, which was specific to the algorithm (see Table 2). In the
real-time case, processing time has been found practically independent of the analysis and detrending method chosen.
3.2. Numerical stability
As numerical stability with fGn signals of identical CV increased towards higher H
true
values, we generated signals of very
low Hurst exponent (H
true
= 0.05) with signal length of N = 2
17
. This test yielded the lower limits of CV of ldDFA a value of
10
3
and for bdSSC that of 10
5
.
We also found that drifting fBm signals showed numerical instability. As seen in Fig. 3, above a critical level of motion in
the fBmsignal, the round-off errors lead to significant bias in the estimates of H (Panel A). This type of error due to persisting
motion was found to accumulate over time (Panel B), which could however be prevented by real-time signal classification.
3.3. Real-time signal classification
DFA and SSC performed comparably (Fig. 4) in that the misclassification rate sharply peaked at 1.044 0.015 and
1.045 0.015, respectively, close to the 1/f boundary on the fBm side. These distributions were not statistically different
(p > 0.05).
3.4. Precision
As for the offline case (Fig. 5A) (see [21,33,35]), precision increased with the signal length for real-time methods too
(Fig. 5B), except in the vicinity of the 1/f boundary.
3.5. Dynamic response to step changes in H
For sliding window length of M = 2
14
, methods do follow the changes in H function properly within the length of
the sliding window. For M = 2
10
, delay in following a descending H was mostly within M data points, while for those of
ascending H values always exceeded the length of the sliding window (Fig. 6).
3.6. In vivo application
Total hemoglobin content (Hb
T
) showed spontaneous fluctuations in addition to the ones of much larger amplitudes
induced by head-up/head-down tilt maneuvers as required by the surgical protocol (Fig. 7). SSC handled artifactual signal
segments with fast dynamics better then DFA, while both methods failed in dealing with slowly developing artifacts. They
performed equally well in segments not showing such artifacts, and

H estimates for both methods reflected the switch from
cardiac to extracorporeal circulation and vice versa.
4. Discussion
In the present paper we first introduced real-time versions of the traditional fractal analysis methods, DFA and SSC; then
evaluated their performance in terms of precision, execution time, numerical stability and dynamic behavior in numerical
experiments and finally applied them to a dynamic physiological signal recorded in a medical environment.
Real-time applications can be found in various fields such as financial market analysis [27,28], engineering [30], medical
monitoring [29]. Typical to all, they do not use a de novo developed real-time algorithm, but instead a real-time-like
adaptation of the original, because the slow dynamics of their anticipated input time series (i.e. stock market index
fluctuation) were expected to allowsufficient time for the original (offline) algorithmto complete estimating a single output
value long before the upcoming update at the input was due. Our approach is thus unique, hence it is based on de novo real-
time algorithms specifically developed to deal with time series with rapid dynamics.
A. Hartmann et al. / Physica A 392 (2013) 89102 97

Fig. 3. Numerical instability and its prevention in the real-time algorithms. Panel A: Above a critical level of motion in the fBmsignal as indicated by H
true
,
the error in

H rapidly increases. Mean error is percent of the total number of analyzing windows (here 32 256) used in the sliding window set (M = 2
10
)
covering the signal in full length (N = 2
17
) as shown in Fig. 2. Panel B: Numerical instability error of real-time DFA for signals at two H
true
as a function of
signal length. Panel C: Error prevention is carried out by real-time signal classification, which proved effective for both SSC and DFA based on a comparison
between their offline and real-time estimates.
We have chosen the widely accepted DFA [32] and its derivative SSC [15] for their known robustness and applicability
to short time series [21,43]; a typical requirement in real-time applications. Moreover, the ldDFA and bdSSC algorithms
could be readily implemented within the constraints of available memory and processing time imposed by the real-time
approach. Other well established or more recently developed methods, such as DMA[44], have also been considered. Though
DFA relies on box division, it yields more accurate

H estimates than DMA, provided that an appropriate detrending method
was applied [33].
Earlier we demonstrated that numerical experiments were needed to characterize the performance of various fractal
tools on synthesized time series with known characteristics, such as their H
true
. The method of Davies and Harte [38] proved
effective and reliable in producing time series of known H
true
, thus it was used in this study too. It is based on producing a
stationary time series of fGn type with known autocorrelation structuring as defined by H
true
[15,21]. We have also pointed
out that when the method of signal generation (i.e. DHM) and that of analysis (i.e. autocorrelation) were interrelated, the
estimate of the Hurst exponent in repeated assessments should be very precise with minimal bias and variance [15]. In this
paper, this problemis avoided by the use of DHMas a method of signal generation independent in its concept fromthe ones
of DFA and SSC as methods of analysis.
98 A. Hartmann et al. / Physica A 392 (2013) 89102
Fig. 4. Precision of real-time signal classification. Real-time DFA and SSC were compared on signals with various H
true
. A total of 19 800 monofractal signals
were generated by DHMin lengths of 2
8
N 2
14
in 7 steps with increments of H
true
= 0.01 for the whole range of the fGn/fBmmodel (0 < H
SSC
, < 2).
Sliding window size (M) was equal to N. The misclassification rate was displayed as as the percentage of total trials at any given H
true
for the range of N.
Misclassification rate did not depend on M, hence data were averaged within each bin of H
true
.
4.1. Execution time
The measured executiontimes of the methods (given inTable 2) were found O(NW). The differences inruntime between
offline algorithms were significantly dependent on the methods implementation (DFA or SSC) and the way of detrending.
Real-time algorithms are closer to each other in design, thus in runtime no remarkable differences were found. Considering
the calculations on the raw and summed signal, the algorithm can easily be parallelized on a multicore CPU, yielding a
manifold increase in performance.
4.2. Numerical stability
Bridge detrending yields a better numerical stability than line detrending does. A possible explanation of this finding is
that line detrending being computationally more complex may introduce larger rounding errors.
The limitations of CV should always be considered. If fluctuations in the time series fall below the given level of CV, the
signal should be transformed so that its CV should exceed a particular threshold before the analysis is to be undertaken. One
way to achieve this is to reduce the mean (i.e. by subtracting a moving average), which would not interfere with the fractal
analysis as fractal estimates in general are invariant to this transformation.
Fromthe stationary character of fGn signals it follows that no persisting deviations fromthe signals mean are seen, thus
CV fluctuates around a constant value. On the contrary, the more persistent the motion in an fBm signal, the more probable
it is that the CV would fall belowthe threshold of the numerically stable analysis. We built on these differences between the
A. Hartmann et al. / Physica A 392 (2013) 89102 99
A
B
C
Fig. 5. Precision of offline and real-time algorithms. A: Precision of offline DFA (a, b) and SSC (c, d) as a function of H
true
and M. M varied from 2
8
to 2
14
and was equal to N. H
true
was increased from 0.01 to 1.99 in steps of 0.01, skipping H
true
= 1. The intensity-coded precision index is given in percent of
estimates of H falling into the range of H
true
0.05 (a, c) or H
true
0.20 (b, d), lighter areas indicate greater precision. B: Precision of real-time DFA (a, b)
and SSC (c, d) as a function of H
true
and M. C: Differential display of results shown in panels A and B.
stationary and nonstationary fGn and fBm signals, and found the solution for preventing this type of error by implementing
real-time signal classification and, upon detecting an fBm signal, the faulty estimate of H as

H
fBm
was substituted for the
correct value represented by

H
fGn
+ 1.
100 A. Hartmann et al. / Physica A 392 (2013) 89102
A B
Fig. 6. Dynamic behavior of our real-time analyses. To test the response for both descending and ascending steps in H, synthetic time series of different
Hurst exponents were concatenated (panel A). In this example, the input was assembled from three fGn time series of length N = 2
16
, generated at
H
true1
= H
true3
= 0.8, H
true2
= 0.2. Known H
true
values used for generating the composite signal (A1), along with the results of its analysis by bdSSC with
analyzing windowlength M = 2
10
and M = 2
14
(A2) and (A3), as well as by ldDFA in (A4) and (A5) are shown. On panel B, mean time delays of the methods
for each H
true1
H
true2
steps are shown, where (H
true1
H
true2
) [0.1, 0.2, . . . , 0.9]
2
, H
1
= H
2
. The sliding window length was set to M
1
= 2
14
(B1) and
M
2
= 2
10
(B2). Length of time series was in both cases N = 2
17
. The number of data points needed to followthe steps with the threshold |H
true


H| < 0.05,
was determined by averaging 10 step responses for each pair of Hurst exponents.
4.3. Real-time signal classification
Both of our real-time methods performed well owing to their very peaked distributions of misclassification rates (Fig. 4).
Due to the methods poor precision near the 1/f boundary (Fig. 5), it is indeed expected that the misclassification rate also
peaks near this boundary. For this reason, when case of fBm is found in error within the range of uncertainty, swapping this
misclassified signals

H for

H
fGn
ought to yield a minimal error in

H due to the narrow range of uncertainty and its peaked
distribution narrowing the range of estimated Hurst exponents from where the substitute

H
fGn
is taken. Also note that both
the precision and misclassification histograms are skewed to the fBm side. This results in an enhanced overall precision of
the real-time algorithms given that the prevention of numerical instability error builds on swapping

H
fBm
for

H
fGn
, the latter
is of increased precision.
4.4. Precision
As shown earlier for power spectral density, dispersional and bridge detrended scaled windowed variance offline
analyses [15,21], the precision of fractal estimates generally increases with signal length. In this study, we performed these
numerical experiments with offline and real-time SSC and DFA methods (Fig. 5), not yet tested for precision in these earlier
studies [15,21]. We also found increased precision with longer signals (corresponding to larger window size, M), more so
with SSC than DFA (notice the larger and lighter areas in panels A and B of Fig. 5. Actually, when comparing (Students t test
at p < 0.05) the mean precision (with tolerance smaller then 0.05 and 0.2) at each M, offline SSC proved superior to offline
DFA for M < 2
14
and M < 2
10
, respectively. Precision of the two real-time methods did not differ. When comparing the
offline and real-time methods, we found that for DFAand SSC alike, their real-time versions provided more precise estimates
of H than their offline equivalents (p < 0.05).
4.5. Dynamic response to step changes in H
Real-time analysis with M = 2
10
could readily follow the abrupt changes in H function (Fig. 6). However the estimates
obtained at larger window length of M = 2
14
produced a more delayed response. A more accurate

H is yielded in the
latter case, since the estimated Hurst exponent fluctuates with a smaller amplitude around H
true
. Consequently, for optimal
selection of the sliding window size one should weight the trade-off between accuracy and response delay according
to the requirements of the particular application. Abrupt changes from lower to higher fractal exponents were followed
A. Hartmann et al. / Physica A 392 (2013) 89102 101

Fig. 7. Application in real-time monitoring of fractality of regional total hemoglobin content fluctuations in the human brain cortex of an anesthetized
patient during cardio-pulmonary bypass surgery. On the top, the change in total hemoglobin concentration (as calculated fromNIRS-signals), on the bottom
the estimated

H is shown as a function of time. Due to the non-pulsatile nature of the heart pump, systolic and diastolic values of arterial blood pressure
(ABP) are shown for periods before and after the segment of extracorporeal perfusion, only. With the sampling frequency of fs = 3.3 Hz and M = 2
10
the
first output from the analysis was obtained at 5 min, and subsequent estimates of H were obtained at every 77.58 s, given that at M = 2
10
, the length of
the largest analyzing window was 2
8
= 256 (see Fig. 1); yielding 77.58 s as 256/3.3 Hz. In the initial period, the hemoglobin signal is contaminated with
significant noise, however it does not affect

H
SSC
(in contrast with

H yielded by real-time DFA). At around 6000 s (shaded area) slowly developing artifacts
can be seen, which could not be handled either by DFA or SSC and resulted in an artifactual increase in

H(t) with a width of M.
significantly faster than in the opposite direction; a finding related to the results of Staudacher et al. [29], who reported a
scaling-dependent method, the Progressive Detrended Fluctuation Analysis for real-time statistical analysis of time series,
and found change-point detection to be asymmetrical.
4.6. In vivo application
During cardiopulmonary bypass the brains hemodynamics is perturbed, and this alteration is reflected in dynamic
fluctuations of the measured total hemoglobin concentration relative to that in a reference condition [17]. In order to capture
these dynamics, the choice of a shorter sliding window size of M = 2
10
was reasonable. When it comes to evaluate the
dynamic informationinour in vivo data (

H(t)), we need to realize that it is a result of a necessary trade-off betweendynamics


and precision in estimating

H. Actually, even though our methods are designed and optimized for real-time applications, the
dynamics in

H(t) is limited by the sampling rate of the measuring device or the processing speed of the computer in addition
to the window size chosen. In our particular case, the limiting factors were the sampling rate of our NIRS instrument being
set at 3.3 Hz and the sliding window size of M = 2
10
, all together yielding an update rate in

H(t) of about 0.01 Hz, which
was sufficient to document the changes in the complexity of brains hemodynamics as they relate to subsequent phases of
the surgery. In future studies, these records can be used to develop algorithms for intraoperative interventions in order to
minimize the cerebrovascular risk to the patient.
Large and rapid perturbations in the Hb
T
signal caused by repositioning the patient (head-up and head-down tilt, i.e.; see
Fig. 7 below 1000 s) were poorly handled by DFA and very well by SSC. The reason is not clear at the moment because the
misclassification rate (see Fig. 4.) and precision (see Fig. 5B) of real-time DFA and SSC are comparable. However, one could
not exclude the possibility that in case of accentuated motion in the signal DFAs approach to detrending may introduce
some bias-related error in F
n
[45]. Artifacts with slow dynamics manifest in increments of the largest analyzing window. In
the particular case of the segment in Fig. 7 at 6000 s, four of such analyzing windows must have been compromised resulting
in an artifact with a length of M.
5. Conclusion
Here we introduced and thoroughly tested real-time versions of fractal analysis methods, DFA and SSC. When comparing
to their offline implementations, we found that the real-time memory requirement and execution time was considerably
lower, while precision did improve. The numerical stability was found to be function of signals variance and mean. Real-
time signal classification proved crucial in the numerically stable handling of strongly persistent signals thus also assuring
improved precision. Our analysis performed well in dealing with dynamic signals in numerical experiments and those
reflecting a real-life scenario such as cerebral hemodynamics monitored in open-heart surgery. Real-time fractal analysis
102 A. Hartmann et al. / Physica A 392 (2013) 89102
can find potential applications in various monitoring systems (medical, meteorological, stock market, etc.) and provide the
needed information to aid decision-making and forecasting.
Acknowledgments
The authors thank to Prof. Dr. Jnos Gl and Dr. Endre Nmeth (Department of Anesthesiology and Intensive Therapy,
Faculty of Medicine, Semmelweis University, Budapest, Hungary) for making the NIRS measurements possible during open-
heart surgery. Dr. Peter Mukli has been supported by the Semmelweis University Magister Project (TMOP-4.2.2/B-10/1-
20100013).
References
[1] B.B. Mandelbrot, J.W. Van Ness, Fractional Brownian motions, fractional noises and applications, SIAM Rev. 10 (1968) 422437.
[2] B. Mandelbrot, The Fractal Geometry of Nature, W.H. Freeman and Company, New York, 1977.
[3] S. Kimiagar, M. Sadegh Movahed, S. Khorram, S. Sobhanian, M.Reza Rahimi Tabar, Fractal analysis of discharge current fluctuations, J. Stat. Mech.
Theory Exp. (2009).
[4] M.S. Santhanam, J.N. Bandyopadhyay, D. Angom, Quantum spectrum as a time series: fluctuation measures, Phys. Rev. E Stat. Nonlin. Soft. Matter.
Phys. 73 (1 Pt 2) (2006) 015201.
[5] L.M. Stadler, B. Sepiol, B. Pfau, J.W. Kantelhardt, R. Weinkamer, G. Vogl, Detrended fluctuation analysis in X-ray photon correlation spectroscopy for
determining coarsening dynamics in alloys, Phys. Rev. E Stat. Nonlin. Soft. Matter. Phys. 74 (4 Pt 1) (2006) 041107.
[6] W.I. Leland, M.S. Taqqu, W. Willinger, D.V. Wilson, On the self-similar nature of ethernet traffic, IEEE/ACM Trans. Netw. 2 (1) (1994) 15 (Extended
version).
[7] M.S. Taqqu, V. Teverovsky, W. Willinger, Is network traffic self-similar or multifractal? Fractals 5 (1997) 6373.
[8] J.B. Rundle, Scaling and critical phenomena in nature, Comput. Sci. Eng. 5 (2003) 8082.
[9] D.L. Turcotte, Fractals and Chaos in Geology and Geophysics, Cambridge University Press, Cambridge, 1997.
[10] E.E. Peters, Fractal Market Analysis. Applying Chaos Theory to Investment and Economics, John Wiley and Sons, New York, 1994.
[11] Z. Xu, Scaling, self-similarity and multifractality in fx markets, Physica A 323 (2003) 578590.
[12] K. Torre, D. Delignieres, Unraveling the finding of 1/f(beta) noise in self-paced and synchronized tapping: a unifying mechanistic model, Biol. Cybern.
99 (2) (2008) 159170.
[13] K. Torre, D. Delignieres, L. Lemoine, 1/f(beta) fluctuations in bimanual coordination: an additional challenge for modeling, Exp. Brain Res. 183 (2)
(2007) 225234.
[14] J.B. Bassingthwaighte, G.M. Raymond, Evaluating rescaled range analysis for time series, Ann. Biomed. Eng. 22 (1994) 432444.
[15] A. Eke, P. Herman, J. Bassingthwaighte, G. Raymond, D. Percival, M. Cannon, I. Balla, C. Ikrnyi, Physiological time series: distinguishing fractal noises
from motions, Pflugers Arch. 439 (2000) 403415.
[16] B. West, Fractal Physiology and Chaos in Medicine, World Scientific Pub. Co. Inc., 1991.
[17] A. Eke, P. Hermn, M. Hajnal, Fractal and noisy CBV dynamics in humans: influence of age and gender, J. Cereb. Blood FlowMetab. 26 (2006) 891898.
[18] D. Lai, Estimating the Hurst effect and its application in monitoring clinical trials, Comput. Statist. Data Anal. 45 (2004) 549562.
[19] S. Monto, S. Vanhatalo, M.D. Holmes, J.M. Palva, Epileptogenic neocortical networks are revealed by abnormal temporal dynamics in seizure-free
subdural EEG, Cereb. Cortex 17 (2007) 13861393.
[20] Z. Chen, P. Ivanov, K. Hu, H. Stanley, Effect of nonstationarities on detrended fluctuation analysis, Phys. Rev. E 65 (2002) 115.
[21] A. Eke, P. Herman, L. Kocsis, L.R. Kozak, Fractal characterization of complexity in temporal physiological signals, Physiol. Meas. 23 (2002) 138.
[22] K. Hu, P. Ivanov, Z. Chen, P. Carpena, H. Eugene Stanley, Effect of trends on detrended fluctuation analysis, Phys. Rev. E 64 (011114) (2001) 119.
[23] D. Delignieres, K. Torre, L. Lemoine, Methodological issues in the application of monofractal analyses in psychological and behavioral research,
Nonlinear Dyn. Psychol. Life Sci. 9 (4) (2005) 435461.
[24] A.V. Coronado, P. Carpena, Size effects on correlation measures, J. Biolog. Phys. 31 (1) (2005) 121133.
[25] A. Carbone, Detrending moving average algorithm: a brief review, 2009, pp. 691696. http://dx.doi.org/10.1109/TIC-STH.2009.5444412.
[26] D.O. Cajueiro, B.M. Tabak, Testing for time-varying long-range dependence in volatility for emerging markets, Physica A 346 (34) (2005) 577588.
[27] J. Alvarez-Ramirez, J. Alvarez, E. Rodriguez, Short-term predictability of crude oil markets: a detrended fluctuation analysis approach, Energy Econ.
30 (5) (2008) 26452656.
[28] Y. Wang, L. Liu, R. Gu, J. Cao, H. Wang, Analysis of market efficiency for the Shanghai stock market over time, Physica A 389 (8) (2010) 16351642.
[29] M. Staudacher, S. Telser, a. Amann, H. Hinterhuber, M. Ritschmarte, A new method for change-point detection developed for on-line analysis of the
heart beat variability during sleep, Physica A 349 (2005) 582596.
[30] L. Vela-Martnez, J. Carlos Jauregui-Correa, E. Rodriguez, J. Alvarez-Ramirez, Using detrended fluctuation analysis to monitor chattering in cutter tool
machines, Int. J. Mach. Tool Manu. 50 (7) (2010) 651657.
[31] N. Brodu, Real-time update of multi-fractal analysis on dynamic time series using incremental discrete wavelet transforms, Arxiv preprint
arxiv:nlin/0511041 (2005).
[32] C.K. Peng, S.V. Buldyrev, S. Havlin, M. Simons, H.E. Stanley, A.L. Goldberger, Mosaic organization of DNAnucleotides, Phys. Rev. E 49 (1994) 16851689.
[33] L. Xu, P. Ivanov, K. Hu, Z. Chen, A. Carbone, H. Stanley, Quantifying signals with power-law correlations: a comparative study of detrended fluctuation
analysis and detrended moving average techniques, Phys. Rev. E 71 (2005) 114.
[34] A. Bashan, R. Bartsch, J. Kantelhardt, S. Havlin, Comparison of detrending methods for fluctuation analysis, Physica A 387 (21) (2008) 50805090.
[35] M. Cannon, D. Percival, D. Caccia, G. Raymond, J. Bassingthwaighte, Evaluating scaled windowed variance methods for estimating the Hurst coefficient
of time series, Physica A 241 (1997) 606626.
[36] T.F. Chan, G.H. Golub, R.J. LeVeque, Algorithms for computing the sample variance: analysis and recommendations, Amer. Statist. 37 (1983) 241247.
[37] D. Caccia, D. Percival, M. Cannon, G. Raymond, J. Bassingthwaighte, Analyzing exact fractal time series: evaluating dispersional analysis and rescaled
range methods, Physica A 246 (1997) 609632.
[38] R.B. Davies, D.S. Harte, Test for Hurst effect, Biometrika 74 (1987) 95101.
[39] IEEE standard for floating-point arithmetic, IEEE, 2008, pp. 158. http://dx.doi.org/10.1109/IEEESTD.2008.4610935.
[40] W. Kahan, J.D. Darcy, E. Eng, H.P.N. Computing, How javas floating-point hurts everyone everywhere, in: ACM 1998 Workshop on Java for High-
Performance Network Computing, 1998, pp. 181.
[41] B. Chance, S. Nioka, Z. Zhao, A wearable brain imager, IEEE Eng. Med. Biol. Mag. 26 (2007) 3037.
[42] L. Kocsis, P. Herman, A. Eke, The modified Beer-Lambert law revisited, Phys. Med. Biol. 51 (5) (2006) N91N98.
[43] D. Delignieres, S. Ramdani, L. Lemoine, Fractal analyses for short time series: A re-assessment of classical methods, J. Math. Psychol. 54 (2006)
525544.
[44] S. Arianos, A. Carbone, Detrending moving average algorithm: A closed-form approximation of the scaling law, Physica A 382 (1) (2007) 915.
[45] R.M. Bryce, K.B. Sprague, Revisiting detrended fluctuation analysis, Sci. Rep. 2 (315) (2012) 16.

You might also like