From: ············@gmail.com
Subject: Re: Random uniform numbers (help)
Date: 
Message-ID: <f5c4c32d-da82-4851-a729-f10fd61a9c1d@a1g2000hsb.googlegroups.com>
On Jul 31, 9:28 pm, Francogrex <······@grex.org> wrote:
> Hi, I am trying to generate random deviates between 8 (that is 11-3)
> and 14 (that is 11+3) using what i wrote below:
>
> ;;Prepare the list
> (setf ls nil)
> ;;Generate the random deviates using random.
> (dotimes (i 500)
> (let ((rn (+ (random 11.0) 3.0)))
> (if (> rn (- 11.0 3.0)) (setf ls (cons rn ls)))))
> ;;test whether you are within the limits
> (apply #'min ls)
> (apply #'max ls)
>
> But this seems to me quite inefficient and bulky, I have a feeling
> there is a more straightforward way but can't find it. Anyone can help
> please? Thanks.

(loop for i from 1 to 500 collect (+ (random 3d0) 11))?

From: ············@gmail.com
Subject: Re: Random uniform numbers (help)
Date: 
Message-ID: <46e5de14-11ba-4476-9da5-b4e7cad1e3de@8g2000hse.googlegroups.com>
On Jul 31, 9:41 pm, ············@gmail.com wrote:
> On Jul 31, 9:28 pm, Francogrex <······@grex.org> wrote:
>
>
>
> > Hi, I am trying to generate random deviates between 8 (that is 11-3)
> > and 14 (that is 11+3) using what i wrote below:
>
> > ;;Prepare the list
> > (setf ls nil)
> > ;;Generate the random deviates using random.
> > (dotimes (i 500)
> > (let ((rn (+ (random 11.0) 3.0)))
> > (if (> rn (- 11.0 3.0)) (setf ls (cons rn ls)))))
> > ;;test whether you are within the limits
> > (apply #'min ls)
> > (apply #'max ls)
>
> > But this seems to me quite inefficient and bulky, I have a feeling
> > there is a more straightforward way but can't find it. Anyone can help
> > please? Thanks.
>
> (loop for i from 1 to 500 collect (+ (random 3d0) 11))?

Of course my previous message is wrong and the correct answer is (loop
for i from 1 to 500 collect (+ (random 6d0) 8))

Carlos
From: Francogrex
Subject: Re: Random uniform numbers (help)
Date: 
Message-ID: <70d7cc7a-b516-4039-b71e-2c499d36d108@y38g2000hsy.googlegroups.com>
On Jul 31, 9:42 pm, ············@gmail.com wrote:
> Of course my previous message is wrong and the correct answer is (loop
> for i from 1 to 500 collect (+ (random 6d0) 8))

That works quite well. Thanks.
From: Thomas A. Russ
Subject: Re: Random uniform numbers (help)
Date: 
Message-ID: <ymi3alocuoj.fsf@blackcat.isi.edu>
············@gmail.com writes:

> (loop for i from 1 to 500 collect (+ (random 6d0) 8))

Or more simply, since you don't need "i":

  (loop repeat 500 collect (+ (random 6d0) 8))


-- 
Thomas A. Russ,  USC/Information Sciences Institute