Re: Random uniform numbers (help)
- From: carlos.ungil@xxxxxxxxx
- Date: Thu, 31 Jul 2008 12:42:53 -0700 (PDT)
On Jul 31, 9:41 pm, carlos.un...@xxxxxxxxx wrote:
On Jul 31, 9:28 pm, Francogrex <fra...@xxxxxxxx> 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
.
- References:
- Random uniform numbers (help)
- From: Francogrex
- Re: Random uniform numbers (help)
- From: carlos . ungil
- Random uniform numbers (help)
- Prev by Date: Re: Random uniform numbers (help)
- Next by Date: Re: The Fundamental Confusion of Xah
- Previous by thread: Re: Random uniform numbers (help)
- Index(es):
Relevant Pages
|