Every HRV number is made in the same four steps: find each heartbeat, measure the gaps between beats, throw out the bad beats, and turn the remaining gaps into one number. This lesson walks through each step, with a calculation you can do on paper.
In lesson 2 you saw the picture behind HRV: a line of gaps between beats that wiggles up and down. In lesson 4 you saw how one bad beat can throw the number off. Now you will see how a device gets from your heartbeat to the number on your screen.
Step 1: find each heartbeat
A device first has to know exactly when each beat happens. There are two main ways to do this.
ECG ECG A recording of the heart's electrical activity, taken with electrodes on the skin. ECG-based RR intervals are the reference standard for measuring HRV. More about ECG (chest straps and medical ECGs). Electrodes on the skin pick up the heart’s electrical signal. Every beat makes a tall, sharp spike called the R peak. Because the spike is so sharp, software can time it very precisely. That is why the ECG is the gold standard for HRV.
PPG PPG An optical method that shines light into the skin and detects the pulse of blood with each heartbeat. Most watches, rings and phone-camera apps use it to estimate HRV. More about PPG (watches, rings and phone cameras). An optical sensor shines light into the skin and measures how much comes back. With each heartbeat, a pulse of blood passes under the sensor and changes the signal. The device times each pulse wave instead of each electrical beat.
The pulse wave reaches your wrist or finger a moment after the heart beats. So, strictly speaking, optical devices measure pulse rate variability Pulse rate variability Variation in the time between pulse beats, measured optically by watches, rings and phone cameras. It closely tracks HRV at rest but drifts from it during movement. More about Pulse rate variability , not heart rate variability. At rest, the two agree well enough for most uses. Optical readings tend to show slightly more short-term variability than the ECG does, partly because breathing affects the pulse on its way to the skin. The match gets much worse when you move. Phone camera apps work on the same principle; see can a phone camera measure HRV.
Step 2: measure the gaps
Next, the device measures the time from each beat to the next, in milliseconds (ms). These are the RR intervals RR interval The time from one heartbeat to the next, measured in milliseconds between the R peaks of an ECG. HRV is calculated from a series of these intervals. More about RR interval you met in lesson 1. A short list might look like this:
810, 830, 790, 850, 820 ms
That is five gaps between six beats. The average gap is 820 ms, which works out to about 73 beats per minute.
Step 3: clean the list
Real recordings are messy. A device can:
- miss a beat (one gap looks twice as long as it should)
- count a beat that wasn’t there (one gap is split into two short ones)
- catch a real extra beat from outside the normal pacemaker, an ectopic beat Ectopic beat A heartbeat that starts outside the heart's normal pacemaker and usually comes early. Ectopic beats are common, but they distort HRV unless removed or corrected. More about Ectopic beat
- pick up noise from movement or a loose strap
Each of these creates a false jump between neighbouring gaps. As you saw in lesson 4, one such jump can multiply RMSSD RMSSD Root mean square of successive differences: an HRV metric built from how much each heartbeat interval differs from the next. It mainly reflects vagal activity. More about RMSSD many times over. In short recordings, even a few edited beats (under 5% of them) can change the result.
So before calculating, software looks for gaps that don’t fit and either removes them or fills them in with a best guess. The gaps that are left, between normal beats, are called NN intervals NN interval An RR interval between two normal heartbeats, after extra beats and measurement errors are removed. Most HRV metrics are calculated from NN intervals. More about NN interval (“normal-to-normal”). One cleaning method published in 2019 caught about 97% of real ectopic beats, and after correction the error in HRV measures was usually under 2%.
You never see this step. Your app does it quietly, using its own method. That is one reason two devices can give different numbers for the same night.
Step 4: turn the gaps into a number
Now for the maths. The main short-term HRV measure is RMSSD, short for “root mean square of successive differences”. The name sounds hard, but it is just four small steps, done in reverse order of the words.
Take our five gaps:
| Gap (ms) | Difference from the gap before (ms) | Difference squared |
|---|---|---|
| 810 | ||
| 830 | +20 | 400 |
| 790 | −40 | 1,600 |
| 850 | +60 | 3,600 |
| 820 | −30 | 900 |
- Successive differences. Subtract each gap from the next one: +20, −40, +60, −30.
- Square. Multiply each difference by itself: 400, 1,600, 3,600, 900. Squaring makes every value positive, so a drop counts as much as a rise. It also gives big jumps extra weight.
- Mean. Average the squares: 6,500 ÷ 4 = 1,625.
- Root. Take the square root: √1,625 ≈ 40.
RMSSD for these five gaps is about 40 ms. In plain words, from one beat to the next, the gap changed by about 40 ms on a typical step.
You’ll often see a second measure next to it, SDNN SDNN The standard deviation of all NN intervals in a recording, in milliseconds. It measures overall variability, and its value depends strongly on how long the recording lasts. More about SDNN . It is the standard deviation of all the gaps, which shows how spread out they are around their average. For our five gaps, SDNN is about 22 ms. Lesson 6 compares the two.
Go deeper The RMSSD formula in symbols
Write the gaps as RR₁, RR₂, … RRₙ. The successive differences are dᵢ = RRᵢ₊₁ − RRᵢ, and there are n − 1 of them.
RMSSD = √( (d₁² + d₂² + … + dₙ₋₁²) ÷ (n − 1) )
With our five gaps, n − 1 = 4 differences, so we divide the sum of squares (6,500) by 4. Real software runs this on cleaned NN intervals, using its own cleaning and averaging, so its result may not match a hand calculation exactly.
SDNN uses the distance of every gap from the average gap instead: square each distance, add them up, divide by n − 1, and take the square root. For 810, 830, 790, 850 and 820, the distances from 820 are −10, +10, −30, +30 and 0. The squares add up to 2,000, and √(2,000 ÷ 4) ≈ 22 ms.
How long to record
So far we used five gaps. Real recordings use many more, and the length matters.
In research, the usual standard for a short-term HRV recording is 5 minutes. Anything shorter is called ultra-short-term. 24-hour recordings are the standard for medical assessment.
RMSSD holds up well in short recordings. In a study of 70 healthy adults, RMSSD from just 1 minute, or even 10 seconds, matched the 5-minute value well. SDNN did not. A much larger study of 3,387 adults found the same: a single 10-second ECG gave a valid RMSSD, averaging three 10-second stretches was better, and 2 minutes was almost as good as the full 5.
Rings and watches that measure while you sleep each pick their own recording windows and their own way of combining them. That is another reason their numbers differ, which lesson 8 covers.
Where errors creep in
The problems below show up at step 1 or step 3:
- Movement. It adds noise to both ECG and PPG, and hurts PPG most.
- Poor contact. A loose strap or electrode, or a ring that slips, can miss beats.
- Extra beats. If cleaning misses them, RMSSD shoots up.
- Sensor type. Optical sensors measure the pulse, not the electrical beat, so they drift further from the ECG during activity.
If you want to compare devices, read is wrist HRV as accurate as a chest strap. For the bigger picture on methods and devices, see how to measure HRV.
That completes Level 1. In the next lesson, RMSSD, SDNN and lnRMSSD, you will compare the main HRV measures and learn which one your app likely shows.