A Rational Analysis of the Selection Task I: Optimal Data Selection