The Dynamics of Discrimination: Theory and Evidence