let of_probability ?(f = round_float_to_int) x = if 0.0 < x && x <= 1.0 then Ok (f (-10. *. log10 x)) else error "invalid probability" x sexp_of_float