Add choose_by_prob function