|
Consolidated response before finalization
John Cowan
(10 Jul 2020 03:23 UTC)
|
|
Re: Consolidated response before finalization Bradley Lucier (10 Jul 2020 18:29 UTC)
|
|
Re: Consolidated response before finalization
Bradley Lucier
(10 Jul 2020 20:33 UTC)
|
|
Re: Consolidated response before finalization
Arvydas Silanskas
(10 Jul 2020 20:49 UTC)
|
|
Which notation is better?
Bradley Lucier
(10 Jul 2020 20:55 UTC)
|
|
Re: Consolidated response before finalization
Linas Vepstas
(10 Jul 2020 18:36 UTC)
|
|
Re: Consolidated response before finalization
Linas Vepstas
(10 Jul 2020 18:46 UTC)
|
|
Re: Consolidated response before finalization
Arvydas Silanskas
(10 Jul 2020 19:38 UTC)
|
|
Re: Consolidated response before finalization
Linas Vepstas
(10 Jul 2020 20:12 UTC)
|
On 7/9/20 11:23 PM, John Cowan wrote:
> Given the existing SRFI 27 facilities (which are included by reference
> in this SRFI), I don't think I'm going to add the round-robin use of
> different sources. You could create a circular generator to provide
> them, just as one possible approach.
>
> I said I would put the gamma and Zipf distributions in if someone
> stepped up to write the code, but no one did. A supplementary SRFI
> could easily add new distributions later, as they are all basically
> independent.
>
> So we're done here for now.
John:
I fear I have been distracted during the period of this SRFI. These are
distracting times.
I'm not sure what you mean by "round-robin use of different sources." I
had previously suggested the routine random-source-generator (see test
example below).
I think this is an important routine if you're going to do a SRFI that
combines random variable generation with generators.
I've done various discrete simulations before, and I'd like to use this
SRFI if I need to do some again. I downloaded the current sources and
made up this little test file that mimics what I might typically need
for a simulation:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define current-random-source (make-parameter default-random-source))
;;; Carefully step through the independent substreams of the i'th
;;; stream of random numbers.
(define (random-source-generator i)
(let ((j 0))
(lambda ()
(let ((new-source (make-random-source))) ;; deterministic
(random-source-pseudo-randomize! new-source i j)
(set! j (+ j 1))
new-source))))
(define (make-exponential-generator mean)
(let ((rand-real-proc (random-source-make-reals
(current-random-source))))
(lambda ()
(- (* mean (log (rand-real-proc)))))))
(define-syntax with-random-source
(syntax-rules ()
((_ random-source proc arg ...)
(begin
(unless (random-source? random-source)
(error "expected random source"))
(parameterize ((current-random-source random-source))
(proc arg ...))))))
;;; Set the number of this experimental run.
(define experiment 0) ;; then 1, 2, ... in later runs.
;;; define random sources for this experiment.
(define sources (random-source-generator experiment))
;;; define N servers with exponentially distributed service
;;; times with given mean.
(define (make-servers N mean)
(let ((result (make-vector N)))
(do ((i 0 (fx+ i 1)))
((fx= i N) result)
(vector-set! result
i
(with-random-source (sources)
(make-exponential-generator
mean))))))
(define servers (make-servers 5 1.0))
(pretty-print (vector-map (lambda (arg) (arg)) servers))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I expected that servers would be a vector of generators, each associated
with my carefully controlled random source (and perhaps each with its
own mean, but not in this example), that I could call when needed.
But it appears that the macro with-random-source actually calls the
generator once, so servers is a vector of reals.
How do I get what I need?
Brad