Efficient sensory encoding predicts robust averaging