HomeArticlesMedical Technology & Imaging Physics

ECG Explained: How the P-QRS-T Wave Encodes a Heartbeat

One electrical wavefront, twelve viewing angles — the Gaussian-sum model behind a synthetic ECG, and how arrhythmias tear the trace apart.

mysimulator teamUpdated July 2026≈ 8 min read▶ Open the simulation

What an ECG actually measures

Every heartbeat starts as a burst of ion current, not a mechanical squeeze. The sinoatrial (SA) node, a small patch of self-exciting cells in the right atrium, spontaneously depolarises about once a second and sends a wavefront of electrical activation racing across the atrial muscle. That wavefront pools at the atrioventricular (AV) node, is deliberately delayed by about 0.1 s so the atria finish emptying into the ventricles first, then rockets down the bundle of His and the Purkinje fibres to depolarise both ventricles almost simultaneously. Each of those moving fronts of depolarising and repolarising tissue creates a tiny, time-varying voltage dipole in the chest, on the order of a millivolt at the skin — small, but easily picked up by electrodes and amplified into the trace a clinician reads.

live demo · a synthetic P-QRS-T trace● LIVE

Building a trace from five Gaussian bumps

A real ECG is generated by solving equations for millions of coupled cardiac cells, which is overkill for an interactive demo. The standard shortcut, popularised by McSharry et al.'s 2003 dynamical ECG model, is to notice that each deflection of a beat — the P wave (atrial depolarisation), the QRS complex (rapid ventricular depolarisation) and the T wave (ventricular repolarisation) — looks close enough to a bell curve that you can build a whole beat as a sum of five asymmetric Gaussians, one centred on each landmark:

z(θ) = Σ_i  a_i · exp( -Δθ_i² / (2 b_i²) )      i ∈ {P, Q, R, S, T}

Δθ_i = θ - θ_i     (angular distance from landmark i on the cardiac cycle)
a_i   = amplitude of that wave  (R is tallest, ~1 mV; P and T are smaller and wider)
b_i   = width of that wave       (QRS is narrow and sharp; T is broad and low)

Each Gaussian's amplitude, width and timing offset from the R peak is tuned to match a textbook trace — a narrow, tall R spike flanked by the small negative Q and S deflections, a gentle P bump beforehand, a broad T bump afterward. Sum the five and repeat once per R-R interval, and the result is visually indistinguishable from a clean lead-II strip. Add a slow baseline wander and a little Gaussian voltage noise and it looks exactly like a real monitor.

12 leads, one heart, twelve angles

A standard clinical ECG does not use one electrode pair, it uses twelve simultaneous views of the same underlying cardiac vector. The limb leads I, II and III form Einthoven's triangle around the torso; aVR, aVL and aVF are mathematically derived "augmented" limb leads; and V1 through V6 wrap across the chest wall from the right sternal border to the left ribcage. Because each lead is really just a projection of the same 3D electrical dipole onto a different axis, a wavefront moving toward a lead's positive electrode swings the trace up, and one moving away swings it down — so the same heartbeat produces twelve different-looking, mutually consistent waveforms, and comparing them is how clinicians localise where in the heart a problem originates.

From steady rhythm to fibrillation

Normal sinus rhythm is simply the same P-QRS-T beat repeating at a steady, physiological rate with one P wave always preceding each QRS. Sinus tachycardia and bradycardia are the same organised beat, just faster or slower than normal. Atrial fibrillation is qualitatively different: the atria stop conducting a single coordinated wavefront and instead fire chaotically from many competing re-entrant circuits, so the P wave disappears into a fine, irregular fibrillatory baseline and the ventricular response — gated unpredictably by the AV node — becomes irregularly irregular. Ventricular tachycardia replaces the narrow QRS with a wide, fast, monomorphic one generated from an abnormal ventricular focus instead of the Purkinje system. Ventricular fibrillation is the most severe: the ventricles lose all organised activity entirely, quivering instead of contracting, and the trace collapses into chaotic, unrecognisable oscillation with no cardiac output — a medical emergency treated only by defibrillation.

Simulating arrhythmias computationally

A Gaussian-sum simulator reproduces each of these presets by perturbing the same five-bump model rather than by modelling every cell. Tachycardia and bradycardia simply shorten or lengthen the R-R interval. Atrial fibrillation drops the P-wave Gaussian and replaces it with low-amplitude high-frequency noise, then randomises the R-R interval beat to beat. Ventricular tachycardia widens and reshapes the QRS Gaussian and speeds the rate dramatically. Ventricular fibrillation abandons the landmark-based model altogether in favour of band-limited chaotic noise with no repeating structure — which is, not coincidentally, exactly what the real electrical activity looks like once it loses organisation.

Frequently asked questions

Why does the same heartbeat look different in each of the 12 leads?

Each lead is a different projection of the same 3D cardiac electrical vector onto a line between two electrodes. Leads I, II and III view the heart from the limbs (Einthoven's triangle), aVR/aVL/aVF are augmented limb leads, and V1-V6 wrap around the chest wall. A wavefront moving toward a lead's positive electrode produces an upward deflection; moving away produces a downward one, so the same beat looks different from every angle.

Why does atrial fibrillation have no P wave?

In atrial fibrillation the atria stop contracting in an organized wavefront and instead activate chaotically at 300-600 times a minute from multiple re-entrant circuits. No single coordinated depolarization survives to produce a clean P wave, so the baseline shows only fine, irregular fibrillatory activity, and because the AV node only lets some of those impulses through, the ventricular response (the R-R interval) becomes irregularly irregular.

What makes ventricular fibrillation immediately life-threatening?

In ventricular fibrillation the ventricles lose all organized electrical activity and quiver chaotically instead of contracting, so the heart pumps essentially no blood. Unlike atrial fibrillation, there is no backup rhythm to fall back on — without defibrillation to reset the electrical chaos within minutes, the chaotic pattern is fatal.

Try it live

Everything above runs in your browser — open ECG Simulator and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open ECG Simulator simulation

What did you find?

Add reproduction steps (optional)