A T-wave alternans measuring apparatus comprising: a grouping section configured to group electrocardiogram waveforms of a subject in increments of a first beat number, to generate a plurality of first groups; a storage section configured to store the electrocardiogram waveforms; a testing section configured to test a statistical intergroup difference of measurement values of the electrocardiogram waveforms of the first groups; a heartbeat condition determining section configured to determine that a heartbeat condition is unstable, when a significant statistical difference exists between the first groups; and a TWA measuring section configured to measure magnitude of TWA by using the electrocardiogram waveforms stored in the storage section, when it is determined that the heartbeat condition is unstable, wherein the TWA measuring apparatus is configured to acquire electrocardiogram waveforms from the subject or comprises an electrocardiogram data inputting section configured to input electrocardiogram data including the electrocardiogram waveforms of the subject, characterised in that the grouping section is configured to group the electrocardiogram waveforms in increments of a second beat number, which is different from the first beat number, to generate a plurality of second groups, the testing section is configured to test a statistical intergroup difference of measurement values of the electrocardiogram waveforms of the second groups, and the heartbeat condition determining section is configured to determine that the heartbeat condition is unstable, when a significant statistical difference exists between the first groups and a significant statistical difference does not exist between the second groups. a grouping section configured to group electrocardiogram waveforms of a subject in increments of a first beat number, to generate a plurality of first groups; a storage section configured to store the electrocardiogram waveforms; a testing section configured to test a statistical intergroup difference of measurement values of the electrocardiogram waveforms of the first groups; a heartbeat condition determining section configured to determine that a heartbeat condition is unstable, when a significant statistical difference exists between the first groups; and a TWA measuring section configured to measure magnitude of TWA by using the electrocardiogram waveforms stored in the storage section, when it is determined that the heartbeat condition is unstable, wherein the TWA measuring apparatus is configured to acquire electrocardiogram waveforms from the subject or comprises an electrocardiogram data inputting section configured to input electrocardiogram data including the electrocardiogram waveforms of the subject, characterised in that the grouping section is configured to group the electrocardiogram waveforms in increments of a second beat number, which is different from the first beat number, to generate a plurality of second groups, the testing section is configured to test a statistical intergroup difference of measurement values of the electrocardiogram waveforms of the second groups, and the heartbeat condition determining section is configured to determine that the heartbeat condition is unstable, when a significant statistical difference exists between the first groups and a significant statistical difference does not exist between the second groups.