The organization of this SRFI Bradley Lucier (19 May 2020 00:06 UTC)
Re: The organization of this SRFI John Cowan (20 May 2020 13:18 UTC)
Re: The organization of this SRFI Bradley Lucier (08 Jun 2020 21:07 UTC)
Re: The organization of this SRFI John Cowan (09 Jun 2020 03:06 UTC)
Re: The organization of this SRFI Bradley Lucier (11 Jun 2020 21:44 UTC)
Re: The organization of this SRFI John Cowan (11 Jun 2020 23:39 UTC)

The organization of this SRFI Bradley Lucier 19 May 2020 00:05 UTC

This SRFI seems to mix together two somewhat separate domains:

1.  Generate random variables with various discrete and continuous
distributions.  This programming is mathematical.

2.  Choose among a selection or range of objects according to results
returned by a random number generator.  This programming supports
various application domains.

I would prefer to see these two domains more separated, even in separate
SRFIs, one mathematical and one not.

I'll list below routines from the SRFI (as it's currently published) in
the different categories, together with some comments.

Brad

1: Basic generator distributions:

(make-normal-generator [ s ] [ mean [ deviation ] ])

I'd prefer to have a N(0,1) generator that is later translated and
scaled by a general transform to fit application needs.

(make-exponential-generator [ s ] mean)

(make-geometric-generator [ s ] p)

(make-poisson-generator [ s ] L)

Missing useful standard distributions:

Bernoulli(p)

Binomial(n,p)

General finite discrete generator: Given probabilities p(i), for i in
[0,N), summing to 1, generate discrete random variable in [0,N) with the
given p(i) as probabilities.

Comment: When you do happen to know probabilities p(i), this generator
would be useful in gweighted-sampling (see my comment below).

More esoteric distributions of varying difficulty and utility:

Gamma

Beta

t

2: Using generators to choose from a given finite set:

(make-random-integer-generator [ s ] lower-bound upper-bound)
(make-random-u8-generator [ s ])
(make-random-s8-generator [ s ])
(make-random-u16-generator [ s ])
(make-random-s16-generator [ s ])
(make-random-u32-generator [ s ])
(make-random-s32-generator [ s ])
(make-random-u64-generator [ s ])
(make-random-s64-generator [ s ])

All these just translate the result of random-integer from SRFI 27.

(make-random-real-generator [ s ] lower-bound upper-bound)

Scales and translates the result from random-real from SRFI 27.  Could
scale and translate any continuous generator.

(make-random-boolean-generator [ s ])

Chooses from #t or #f, with a fixed probability of #t.  Should use a
probability p for #t, i.e., a Bernoulli distribution.

(make-random-char-generator [ s ] string)

Again, uses random-integer from SRFI 27 to select from a set.  Should
use any discrete distribution generator with range [0,(string-length
string).

(make-random-string-generator [ s ] string)

I don't understand what this one does.

(gsampling [ s ] generator ...)

I don't understand the statement "When all the generators are exhausted
or no generators are specified, the new generator returns an end-of-file
object."  Choosing among the generators with equal probability is an
unnecessary limitation.

(gweighted-sampling) [ s ] obj ..)

You probably want to choose randomly from N generators based on the
output of an N+1st generator that has range [0,N).  Specifying
probabilities (basically the probability distribution function of a
discrete random variable) is too difficult in general.