The identification of peaks is fundamental in the processing of physiological signals. For example, it is common to the analysis of electrocardiograms, electroencephalograms, sympathetic neuronal activity, pulse oximetry, respiratory movement, hormone pulse secretion, and even chromatography. Often it is necessary to detect peaks in real time, but the task is frequently complicated by baseline wander and other interference. Current approaches to the problem tend to be complicated, specific to a particular domain, and reliant on several tunable parameters. There is a need for a simple and general mathematical formalization of peaks and troughs that has easily examinable properties and is readily implementable as an efficient algorithm. In this paper we present such a mathematical model together with an algorithm for the detection of peaks and troughs. We illustrate the generality of the method with some actual physiological data.