Apparatus and methods are described for monitoring a subject. A sensor is configured to monitor the subject without contacting the subject or clothes the subject is wearing, and without viewing the subject or clothes the subject is wearing, and to generate a sensor signal in response to the monitoring. A computer processor is configured to: (a) receive the sensor signal, (b) extract from the sensor signal a plurality of heartbeats of the subject, and, for each of the extracted heartbeats, an indication of a quality of the extracted heartbeat, (c) select a subset of heartbeats, based upon the qualities of the extracted heartbeats, (d) for only the subset of heartbeats, determine interbeat intervals between adjacent heartbeats, (e) in response thereto, determine a physiological state of the subject, and (f) generate an output in response thereto. Other applications are also described.