This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Did you know that `random' in slib has been broken for several years? Try this: (define (flip-coins n) (let* ((m 170) (h (/ m 2))) (do ((i 0 (+ i 1)) (heads 0 (if (> (random m) h) (+ heads 1) heads))) ((= i n) heads)))) The problem is that the modulo operation used to map the random bits onto the appropriate interval wraps numbers around so that parts of the interval can get more hits than others. Tomorrow's snapshot contains a new built in generator.