A T-wave alternans (TWA) measuring apparatus is configured to group electrocardiogram (ECG) waveforms in increments of a first beat, to test a statistical intergroup difference for the correponding first groups, and to determine that a heartbeat condition is unstable, when a significant statistical difference exists between the first groups. The apparatus is further configured to determine the magnitude of TWA when it is determined that the heartbeat condition is unstable. The ECG waveforms may further be grouped in increments of a second beat number to generate second groups, and to determine that the heartbeat condition is unstable when a significant statistical difference exists between the first groups but not between the second groups.