A heartrate monitor detects heartbeats in a test signal. A local heartrate and an energy of acceleration are associated with the detected heartbeats. Detected heartbeats are included or excluded 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 using a sparse approximation model. 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.