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)

Re: Consolidated response before finalization Bradley Lucier 10 Jul 2020 20:33 UTC

On 7/10/20 2:29 PM, Bradley Lucier wrote:

>
> ;;; 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.

It appears I need instead

(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)))))

So I think that there need be only

(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))))

Brad