From 531df9590d006434b31cc81871b73c31ca9f896b Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 10 Jan 2019 17:12:56 +0000 Subject: Move ceil call back into the geometric sampler. Test exactly what the geometric sampler returns, because that's what the downstream callers of it are going to use. While here, also assert that the geometric sampler returns a positive integer. (Our geometric distribution is the one suported on {1, 2, 3, ...} that returns the number of trials before the first success, not the one supported on {0, 1, 2, ...} that returns the number of failures before the first success.) --- src/lib/math/prob_distr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/math/prob_distr.c b/src/lib/math/prob_distr.c index f5e5218aa7..e170d000fe 100644 --- a/src/lib/math/prob_distr.c +++ b/src/lib/math/prob_distr.c @@ -1308,7 +1308,7 @@ sample_geometric(uint32_t s, double p0, double p) if (p >= 1) return 1; - return (-x/log1p(-p)); + return ceil(-x/log1p(-p)); } /*******************************************************************/ -- cgit v1.2.3-54-g00ecf