Detrended Fluctuation Analysis: Formula and Worked Example

Detrended fluctuation analysis (DFA) measures how strongly a time series "remembers" its own past. It integrates the signal, removes a local linear trend in windows of size n, and tracks how the leftover fluctuation F(n) grows as n increases; the slope of log F(n) against log n is the scaling exponent α. An α near 0.5 means no memory, above 0.5 means persistent correlations, and below 0.5 means the series tends to reverse itself.

Detrended Fluctuation Analysis: Formula and Worked Example

Kristian Hoffmann · SaaS founder and operator

Detrended fluctuation analysis (DFA) measures how strongly a time series "remembers" its own past. It integrates the signal, removes a local linear trend in windows of size n, and tracks how the leftover fluctuation F(n) grows as n increases; the slope of log F(n) against log n is the scaling exponent α. An α near 0.5 means no memory, above 0.5 means persistent correlations, and below 0.5 means the series tends to reverse itself.

What does detrended fluctuation analysis actually measure?

DFA estimates long-range correlation in a signal that may also drift. Ordinary autocorrelation struggles when the mean of a series wanders, for example a heartbeat series during a step test where heart rate rises stage by stage. DFA deals with this by fitting and subtracting a trend inside each window before measuring variability. Whatever drift the trend line absorbs no longer counts as correlation.

The output is one number, the scaling exponent α (alpha). It is the exponent in the power law F(n) ∝ n^α. If doubling the window size multiplies the fluctuation by 2^0.5 ≈ 1.41, then α = 0.5. A larger factor gives a larger α.

The method was popularised for physiological signals by Peng and colleagues in their 1995 paper Quantification of scaling exponents and crossover phenomena in nonstationary heartbeat time series (Chaos, vol. 5). DFA has since been applied to earthquake records, financial series, gait, audio and much else. For a lactate-testing audience, the relevant application is a narrow one: short-term DFA of beat-to-beat heart rate intervals, usually called DFA α1.

How is the DFA formula calculated, step by step?

Start with a series x(1) … x(N), such as RR intervals in milliseconds (the time between consecutive heartbeats).

  1. Subtract the mean and integrate. Build the profile y(k) = Σ [x(i) − x̄] for i = 1 … k. This running sum is the "random walk" version of the signal.
  2. Cut the profile into boxes of n points each, without overlap.
  3. Fit a straight line inside each box by least squares. That line, y_n(k), is the local trend. Fitting a straight line gives DFA1; fitting a quadratic gives DFA2, and so on.
  4. Compute the fluctuation: F(n) = √[ (1/N) · Σ (y(k) − y_n(k))² ], summed over every point in every box.
  5. Repeat for several box sizes n and plot log F(n) against log n.
  6. Read α as the slope of that line.

Which α values mean what in DFA?

These reference values come from the definition of the method, not from any study population:

α rangeSignal behaviourPlain-language reading
below 0.5Anti-correlatedLarge values tend to be followed by small ones
about 0.5Uncorrelated (white noise)No memory
0.5 to 1.0Persistent, long-range correlatedLarge values tend to follow large values
about 1.01/f ("pink") noiseCorrelations across many scales
about 1.5Brownian noise (integrated white noise)Strongly drifting, random-walk-like

How does DFA relate to the Hurst exponent?

For a stationary, fractional-Gaussian-noise-type signal, α equals the Hurst exponent H. For a non-stationary, random-walk-type signal, α ≈ H + 1, which is why DFA values can exceed 1 while H stays between 0 and 1. Rescaled-range analysis and Bayesian estimators target H directly. DFA became popular because its preprocessing step tolerates drifting signals.

Detrended fluctuation analysis example: an 8-beat hand calculation

Example: the following RR series is fictional and deliberately tiny so every step can be checked with a calculator. Real analyses need far more data; the purpose here is to show where each number comes from.

Input (ms): 800, 810, 790, 820, 805, 795, 815, 785. Mean = 6,420 / 8 = 802.5 ms.

Step 1: deviations and profile.

Beat kRR (ms)x − meanProfile y(k)
1800−2.5−2.5
2810+7.55.0
3790−12.5−7.5
4820+17.510.0
5805+2.512.5
6795−7.55.0
7815+12.517.5
8785−17.50.0

Box size n = 4

Box 1 (beats 1–4) has a fitted slope of +2.5, giving trend values −2.5, 0, 2.5, 5.0. The residuals are 0, 5, −10, 5, and their squares sum to 150.

Box 2 (beats 5–8) has a fitted slope of −2.5, giving trend values 12.5, 10, 7.5, 5.0. The residuals are 0, −5, 10, −5, and again the squares sum to 150.

F(4) = √(300 / 8) = √37.5 ≈ 6.12 ms.

Box size n = 8

One box covers all eight beats. The least-squares slope is 60 / 42 ≈ 1.43 per beat, with the line running from 0 to 10. The squared residuals sum to about 389.3.

F(8) = √(389.3 / 8) = √48.66 ≈ 6.98 ms.

Resulting α

α = log(F(8) / F(4)) / log(8 / 4) = ln(1.139) / ln(2) ≈ 0.130 / 0.693 ≈ 0.19.

That is well below 0.5, and the raw data show why. The series alternates almost every beat (high, low, high, low), which is anti-correlated behaviour. Doubling the window barely increases the fluctuation, because the zig-zags cancel out instead of building up. A smoother series that drifts in one direction would give a much steeper F(n) curve and a higher α.

Two box sizes give a line through two points, so the fit has no error estimate at all. This is the first failure mode to watch for in any DFA output: an α computed from too few boxes or too few box sizes looks just as precise as a well-founded one.

How much data does DFA α1 need from a heart rate recording?

Short-term DFA of heartbeats usually uses small boxes, roughly 4 to 16 beats. The number of independent boxes you get depends on heart rate and window length, and so does the stability of the estimate.

Example: assume a 2-minute analysis window and a box range of 4 to 16 beats.

Heart rateBeats in 2 minBoxes at n = 4Boxes at n = 16
60 bpm120307
100 bpm2005012
150 bpm3007518

At rest, the largest box size rests on just seven boxes, so the top end of the log-log line is noisy. During hard steps the same 2-minute window holds more than twice the data. In practice, an α1 value from a low-heart-rate warm-up stage carries more uncertainty than one from a later stage, even when the software shows both to two decimal places.

Which recording errors distort DFA α1?

  • Artifacts and ectopic beats. One missed or doubled beat creates an RR value that is roughly double or half its neighbours. Because DFA integrates the series, that spike stays in the profile for the rest of the window. Check what share of beats the software corrected, and discard windows where that share is high.
  • Optical vs chest-strap sensors. DFA needs beat-to-beat RR timing, not a smoothed bpm display. Check whether your device exports true RR intervals.
  • Windows that span a stage change. If a 2-minute window straddles the jump from one step to the next, the detrending line has to absorb a step change it was never designed for.
  • Mismatched box ranges. α1 from boxes 4–16 and α from boxes 4–64 are different numbers. Compare values only when the box range and the detrending order are the same.

Can DFA α1 replace a lactate step test for LT1 and LT2?

DFA α1 and blood lactate measure different things. Lactate is a metabolic concentration in mmol/L, sampled at the end of each stage. DFA α1 describes the correlation structure of heartbeat timing, and that structure changes as intensity rises. The group around Rogers and Gronwald has proposed fixed α1 values as markers: α1 = 0.75 near the first ventilatory threshold (Rogers et al. 2021, Front Physiol) and α1 = 0.5 near the second (Rogers et al. 2021, J Funct Morphol Kinesiol). Each study tested 15 people on a treadmill and compared against gas-exchange thresholds, not blood lactate. Agreement with lactate-based thresholds varies between individuals, sports and protocols, so treat any such cut-off as a hypothesis for your own data rather than as a calibrated threshold.

A practical workflow is to collect both signals in the same session:

  1. Run a standard step test with lactate sampled at the end of each stage.
  2. Record RR intervals with a chest strap throughout.
  3. Calculate LT1 and LT2 from the lactate curve, and calculate α1 per stage separately.
  4. Write down the stage at which α1 drops below whatever reference value your software uses (α1 falls as intensity rises), and compare it with the lactate-derived LT1 power or pace.
  5. Repeat on the next test before trusting the relationship.

Example of a before/after comparison: assume LT1 from lactate lands at 205 W, and the α1 crossing in the same session falls at 225 W. That 20 W gap is the number to log. Run the same protocol a few weeks later. If the gap is similar, the HRV marker may be useful as an in-between check for that athlete. If it swings from +20 W to −15 W, it is not yet telling you anything you can act on. Decisions about training load or health still belong with a qualified coach or physician, not with a single exponent.

Indoor trainer tests in December and January suit this comparison, because temperature, posture and power measurement stay stable between sessions. For lactate-side data quality, the step test analysis article comparing four threshold methods shows how far LT estimates can move with the method alone. That spread is the yardstick for judging whether an α1 gap is meaningful or just method noise.

How do you choose DFA software or a Python implementation?

Search interest in "detrended fluctuation analysis Python" reflects that most people end up scripting DFA rather than running it from a menu. Whatever implementation you choose, check these settings before you compare any outputs:

SettingWhat to checkWhy it changes α
Detrending orderLinear (DFA1) or higherHigher orders remove curvature and can lower α
Box sizesMinimum, maximum, spacing (linear or log)α1 and α2 cover different scales
OverlapNon-overlapping or sliding boxesAffects variance of F(n), especially for short series
IntegrationWhether the input is already integratedIntegrating twice adds about 1 to α
Artifact handlingInterpolation, deletion, thresholdUncorrected beats leave a step in the profile
Window length and stepe.g. 2 min, updated every few secondsShort windows mean few boxes at large n

The "integrating twice" row is a frequent silent bug. Some libraries expect the raw series and integrate it internally. If you pass a cumulative sum, the reported α jumps by about one unit, for example a white-noise-like signal read as Brownian.

A useful sanity check is to generate synthetic white noise, run your pipeline and confirm that α comes out close to 0.5. Then shuffle your real RR series and run it again. Shuffling destroys correlations, so α should fall towards 0.5. If it does not, the pipeline is measuring something other than correlation structure.

Lactate tools work at a different layer. They take stage values in mmol/L and fit a curve rather than estimate a scaling exponent. The guide on how to choose lactate test analysis software covers the methods (Dmax, fixed values and others) that you would compare an α1 marker against.

FAQ

What is DFA in statistics?

In time-series statistics, DFA is detrended fluctuation analysis: a method for estimating long-range correlations and fractal scaling in signals that may not be stationary. The same acronym is also used for discriminant function analysis, a classification method that assigns cases to groups from predictor variables. The two methods are unrelated, so check the context before reading any "DFA" result.

Is a DFA α of 1.0 good or bad?

Neither in itself. α ≈ 1.0 describes 1/f-type correlations. Whether that is expected depends on the signal, the box range and the conditions. For heart rate data in particular, a single α value is not a health assessment.

Why does my DFA α exceed 1?

Values above 1 point to non-stationary, random-walk-like behaviour. They can also come from feeding an already integrated series into code that integrates it again, so rule that out first.

How many data points does detrended fluctuation analysis need?

There is no single cut-off. The deciding factor is how many boxes fit at your largest box size. With fewer than about ten boxes at the top of the range, as in the 60 bpm row of the table above, the upper end of the log-log fit becomes unstable. Lengthen the window or narrow the box range.

Can I get DFA α1 from a lactate meter?

No. A lactate meter gives blood lactate concentration per sample. α1 needs continuous beat-to-beat RR intervals from a heart rate sensor. The two can be recorded in the same step test and compared afterwards, as described in Self test lactate analysis online: measure and interpret results, which covers the lactate side of that session.