A helper function to calculate quantiles from unique values and probabilities