Gradient flows and randomised thresholding: sparse inversion and classification