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.
How often the sensor looks
A sensor does not watch your heart all the time. It takes snapshots, many times a second. The number of snapshots a second is the sampling rate Sampling rate How many times a second a sensor measures the signal, in hertz (Hz). It sets how precisely each beat can be timed: about ±1 ms at 1000 Hz, ±4 ms at 250 Hz and ±20 ms at a 25 Hz camera. More about Sampling rate , in hertz (Hz). A device can only place a beat on one of its snapshots, so a beat’s time is rounded to the nearest one.
Rounding to the nearest snapshot moves a beat by at most half the gap between snapshots. At 1000 Hz the snapshots are 1 ms apart, so a beat lands within 0.5 ms of its true time; at 250 Hz, within 2 ms. A phone camera takes about 25 to 30 pictures a second, so each beat can be off by up to 20 ms. The 2024 research guidelines quote a more cautious figure, a whole gap (±1 ms at 1000 Hz, ±4 ms at 250 Hz), and recommend 1000 Hz (Quigley and colleagues, 2024).
This matters most for RMSSD RMSSD Root mean square of successive differences: an HRV metric built from how much each heartbeat interval differs from the next, in milliseconds. It mainly reflects vagal activity. More about RMSSD . RMSSD measures the change from one gap to the next, and rounding errors look exactly like such changes. Time every beat of this course’s five-minute teaching recording to the nearest of 25 pictures a second, and RMSSD reads 31% too high, about a third. Software can win much of this back by estimating where the pulse peak fell between two pictures. Lesson 16, in the Analyst level, lets you try every sampling rate yourself: from electrode to number.
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 Sinus node The heart's natural pacemaker, a small patch of cells that starts every normal heartbeat. Left alone it fires about 100 times a minute; the vagus nerve holds it lower at rest. More about Sinus node , 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 many times over. In short recordings, even a few edited beats (under 5% of them) can change the result.
So before calculating, software cleans the list in two steps. The gaps that are left, between normal beats, are called NN intervals NN interval An RR interval between two normal heartbeats, in milliseconds, after extra beats and measurement errors are removed. Most HRV metrics are calculated from NN intervals. More about NN interval (“normal-to-normal”).
First, find the bad gaps. The usual rule compares each gap with its neighbours and flags any that differ from them by more than a set amount. A strict rule catches small errors but starts flagging real beats; a loose one lets errors through.
Then, fix them. The software either deletes the bad gap or fills it with a value made from the good gaps around it. Filling keeps the recording’s rhythm in step, which matters for some measures; deleting is simpler (Peltola, 2012).
How much fixing is too much? Editing even under 5% of the gaps can change short-term results, and many studies throw out a recording with under 80% normal beats (Peltola, 2012). The guide to Kubios, a widely used research program, recommends keeping corrected beats Beat correction Finding the beat intervals that are wrong (missed, extra or ectopic beats) and deleting or replacing them before HRV is calculated. The rule of thumb is to correct under 5% of beats. More about Beat correction under 5% (Alcantara and colleagues, 2020).
Lesson 16 names the cleaning methods, compares them on a five-minute recording and lets you plant a bad beat and clean it yourself.
You never see this step. Your app does it quietly, using its own method and threshold. 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.
Now try it on a longer list. The widget below works RMSSD out step by step from ten beats of the site’s teaching recording. Press Next to move through the steps, or change any beat and watch every step update.
RMSSD step by step
Ten beats, every number shown
RMSSD of these 10 intervals is 26.9 ms.
Step 5 of 5
Step 1 of 5 Start with the intervals
Beat 1 880 ms Beat 2 826 ms Beat 3 812 ms Beat 4 823 ms Beat 5 848 ms Beat 6 877 ms Beat 7 880 ms Beat 8 866 ms Beat 9 828 ms Beat 10 815 ms 10 intervals between 11 beats, in milliseconds.
Step 2 of 5 Subtract each interval from the next
Beat 2 − beat 1 −54 ms Beat 3 − beat 2 −14 ms Beat 4 − beat 3 +11 ms Beat 5 − beat 4 +25 ms Beat 6 − beat 5 +29 ms Beat 7 − beat 6 +3 ms Beat 8 − beat 7 −14 ms Beat 9 − beat 8 −38 ms Beat 10 − beat 9 −13 ms Plus means the heart slowed down for a beat; minus means it sped up.
Step 3 of 5 Square each difference
Difference 1 2916 Difference 2 196 Difference 3 121 Difference 4 625 Difference 5 841 Difference 6 9 Difference 7 196 Difference 8 1444 Difference 9 169 Sum 6517 Squaring makes every value positive and gives big changes more weight.
Step 4 of 5 Average the squares
6517 ÷ 9 724.11 Step 5 of 5 Take the square root
√724.11 26.9 ms RMSSD 26.9 ms
With JavaScript on, the steps show one at a time and the beats can be changed.
A row of ten editable heartbeat intervals in milliseconds, then the calculation of RMSSD as numbered steps: start with the intervals; subtract each interval from the next; square each difference; average the squares; take the square root. The final step reads RMSSD 26.9 ms. Back and Next buttons move between the steps.
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 long-term HRV, which is used mostly in medical research.
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 matched a 4 to 5 minute recording almost perfectly.
SDNN behaves differently because it measures the spread of all the gaps, slow changes included. A longer recording takes in slower rhythms, from posture and activity to the day-night cycle, so SDNN keeps growing with length. Drag the window below from 5 minutes to 24 hours on a simulated day: RMSSD barely moves, SDNN almost triples.
How long should you record?
A simulated day, not a person
- RMSSD
- 37.2 ms
- SDNN
- 29.7 ms
- Beats in the window
- 327
Over 5 min, RMSSD is 37.2 ms and SDNN 29.7 ms. This is the short-term standard.
The slider works when JavaScript is on.
A chart of RMSSD and SDNN against recording length on a logarithmic axis from 10 seconds to 24 hours. The RMSSD line stays close to 37 ms at every length. The SDNN line sits near 30 ms up to a few minutes and climbs to about 84 ms at 24 hours. Dashed marks show the minimum lengths: 1 minute for the HF band, 2 minutes for LF, 5 minutes for the short-term standard and the VLF band, 20 minutes for DFA alpha 2, and 24 hours for ULF and long-term SDNN. A slider picks the window length, and readouts give RMSSD, SDNN and the number of beats in the window.
Each measure needs a minimum length:
| Measure | Shortest useful recording | Source |
|---|---|---|
| RMSSD | 10 seconds to 1 minute; longer is steadier | Munoz 2015; Nussinovitch 2011 |
| SDNN | At least 30 seconds, and only comparable at the same length | Munoz 2015; Shaffer and Ginsberg 2017 |
| Long-term SDNN | 24 hours | Shaffer and Ginsberg 2017 |
Measures that split HRV into slow and fast rhythms need longer recordings, and sources differ on how much longer. Lesson 18 sets out the rules and where they disagree.
Numbers from recordings of different lengths should not be compared. A 24-hour SDNN carries information about heart risk that a 5-minute SDNN does not (Shaffer and Ginsberg, 2017).
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.