Individual histories and selection in heterogeneous populations