Comments about code. Bradley Lucier (28 Jul 2020 02:34 UTC)
Re: Comments about code. Arvydas Silanskas (28 Jul 2020 07:54 UTC)
Re: Comments about code. Linas Vepstas (28 Jul 2020 14:42 UTC)
Re: Comments about code. John Cowan (28 Jul 2020 17:02 UTC)

Comments about code. Bradley Lucier 28 Jul 2020 02:34 UTC

I'm working on (make-binomial-generator n p), so I'm looking at the
existing code in

https://github.com/arvyy/srfi-194/blob/master/srfi-194-impl.scm

Here are some comments:

-- make-random-integer-generator: I think you want to check that
low-bound and up-bound are exact integers, because rand-int-proc takes
an exact integer for an argument.

-- clamp-real-number: I think you want to check that lower-bound and
upper-bound are real.

-- make-random-real-generator: I think you want to check that low-bound
and up-bound are real and finite.

-- make-bernoulli-generator: Check that p is real.

-- make-categorical-generator: If pvec is a vector of inexact numbers,
it's quite unlikely that they'll add exactly to 1.  So some "slop"
(1e-13 maybe) is called for here, but I don't know how to combine this
with your linear search in line 130.

-- make-normal-generator: check that mean and deviation are finite real
numbers, and that deviation is positive.

-- make-exponential-generator: Check that mean is real and finite.

-- make-geometric-generator, line 174, I think you want

       (exact (ceiling (* c (log (rand-real-proc))))))))

to make the result an exact integer. Check that p is real and between 0
and 1.

-- make-poisson-generator: Check that L is a positive real number.