[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] srfi-27 - producing pseudo and truly random numbers over
From: |
Terrence Brannon |
Subject: |
[Chicken-users] srfi-27 - producing pseudo and truly random numbers over a uniform distribution |
Date: |
Sun, 28 Oct 2007 17:55:06 -0400 |
In addition to the bug I filed on this egg - http://trac.callcc.org/ticket/346
I have a question about common usage of this module.
I would like to produce one function, roll-fixed, which produces
pseudorandom numbers in the documented fashion of random-real and
random in SRFI-27. Such that the sequence of randoms (over a uniform
distribution) is predictable on each new startup of the intepreter:
(define *fixed-seed* (expt 7 5))
(define roll-fixed
(let ([side-effect (set-seed *fixed-seed*)])
(lambda (n)
(if (zero? n)
(random-real-based-on-fixed-seed)
(random-integer-based-on-fixed-seed n)))))
Additionally, I would like a function, roll-truly-random, which again
can produce reals or integer randoms, but whose sequence of randoms
(over a uniform distribution) is different across each new startup of
the interpreter.
(define roll-truly-random
(let ([side-effect (set-seed (truly-random-seed))])
(lambda (n)
(if (zero? n)
(random-real-based-on-truly-random-seed)
(random-integer-based-on-truly-random-seed n)))))
I'm sorry to beg for such hand-holding, but it seems like the Issues
section of the docs does admit that this library could use a few good
examples. It also mentions that the API creates something of a hurdle
for my desire to have two distinct random structures available in two
distinct functions.
- [Chicken-users] srfi-27 - producing pseudo and truly random numbers over a uniform distribution,
Terrence Brannon <=
Re: [Chicken-users] srfi-27 - producing pseudo and truly random numbers over a uniform distribution, Terrence Brannon, 2007/10/29