The distribution of class groups of imaginary quadratic fields