A heartrate monitor detects (1604) heartbeats in a test signal. A local heartrate and an energy of acceleration are associated (1606, 1608, 1610) with the detected heartbeats. Detected heartbeats are included or excluded (1612) from a test set of heartbeats based on the local heartrate and energy of acceleration associated with the respective heartbeats. Anomalous heartbeats in the test set of heartbeats are detected (1622) using a sparse approximation model (1620). The heartrate monitor may detect heartbeats in a training heartbeat signal. A reference heart rate and an energy of acceleration are associated with detected beats of the training heartbeat signal and selectively included in a set of training data based on the heart rate and energy of acceleration associated with the detected beat in the training heartbeat signal. A dictionary of the sparse representation model may be generated using the set of training data.