A Theoretical Analysis of the Learning Dynamics under Class Imbalance