Distance-based optimal discretization of a continuous probability distribution