We had this previously, but we did it differently in different places. This implementation is pulled from test_prob_distr.c