Optimal Selection from a Random Sequence with Learning of the Underlying Distribution