Perception as hypothesis testing