Visual LISP, AutoLISP and General Customization

Reply
*Guidi, Gustavo
Message 1 of 15 (119 Views)

Random number

119 Views, 14 Replies
12-13-2000 08:14 AM
How can I generate a random number in LISP or VLISP

Thanks
*Wold, Rune
Message 2 of 15 (119 Views)

Re: Random number

12-13-2000 08:35 PM in reply to: *Guidi, Gustavo
For a random number 0-9:

(atoi (substr (rtos (getvar "cdate") 2 8) 17))

--
Rune Wold
System Analyst
Engineering Systems
rune@engsys.no
--
*Fugier, Dale
Message 3 of 15 (119 Views)

Re: Random number

12-13-2000 11:51 PM in reply to: *Guidi, Gustavo
Hi Gustavo,

DOSLib has a dos_random function which uses the rand/srand C/C++ standard
library functions. You can get DOSLib free from www.mcneel.com.

--

Dale Fugier
Robert McNeel & Associates
www.mcneel.com

"Gustavo Guidi" wrote in message
news:ef5b25b.-1@WebX.SaUCah8kaAW...
> How can I generate a random number in LISP or VLISP
>
> Thanks
>
*Guidi, Gustavo
Message 4 of 15 (119 Views)

Re:

12-13-2000 11:51 PM in reply to: *Guidi, Gustavo
Thankyou
*Schulte, S.
Message 5 of 15 (119 Views)

Re: Random number

02-06-2002 01:28 AM in reply to: *Guidi, Gustavo
What ways are you creating random numbers? Thanks for your reply.
--
S. Schulte
Computer Specialist
Missouri Dept. of Conservation
schuls@mail.conservation.state.mo.us
*mataeux
Message 6 of 15 (120 Views)

Re:

02-06-2002 01:28 AM in reply to: *Guidi, Gustavo
What ways are you testing to see if your random number is random enough?


S. Schulte wrote in message
news:60F36F14D99F9C5562491C3C3C51D8F9@in.WebX.maYIadrTaRb...
> What ways are you creating random numbers? Thanks for your reply.
> --
> S. Schulte
> Computer Specialist
> Missouri Dept. of Conservation
> schuls@mail.conservation.state.mo.us
>
>
*DonB
Message 7 of 15 (120 Views)

Re:

02-06-2002 04:19 AM in reply to: *Guidi, Gustavo
Don't laugh

(/ (rem (+ (* 25173 (getvar "date")) 13849) 65536) 65536)

Don

"S. Schulte" wrote in message
news:60F36F14D99F9C5562491C3C3C51D8F9@in.WebX.maYIadrTaRb...
> What ways are you creating random numbers? Thanks for your reply.
> --
> S. Schulte
> Computer Specialist
> Missouri Dept. of Conservation
> schuls@mail.conservation.state.mo.us
>
>
*LEsquivel
Message 8 of 15 (120 Views)

Re:

02-06-2002 05:53 AM in reply to: *Guidi, Gustavo
; Random number generator
(defun random ()
(setq seed (if seed (rem (+ (* seed 15625.7) 0.21137152) 1) 0.3171943)))
*DonB
Message 9 of 15 (120 Views)

Re:

02-06-2002 06:28 AM in reply to: *Guidi, Gustavo
Much better since mine doesn't work .

I ran your through 10,000 iterations without a duplicate.

Don

"LEsquivel" wrote in message
news:E22144BD5CC558845EBB4D3DA414EB51@in.WebX.maYIadrTaRb...
> ; Random number generator
> (defun random ()
> (setq seed (if seed (rem (+ (* seed 15625.7) 0.21137152) 1) 0.3171943)))
>
>
>
*DonB
Message 10 of 15 (120 Views)

Re:

02-06-2002 06:48 AM in reply to: *Guidi, Gustavo
Hi Luis,

Remember, I said don't laugh

My function should have read...

(defun randnum ()
(if (not seed)(setq seed (getvar "date")))
(setq seed (rem (+ (* 25173 seed) 13849) 65536))
(/ seed 65536)
)

I ran both of our functions through 10,000 iterations without duplicates.

What do you use the random number for typically?

Don





"LEsquivel" wrote in message
news:E22144BD5CC558845EBB4D3DA414EB51@in.WebX.maYIadrTaRb...
> ; Random number generator
> (defun random ()
> (setq seed (if seed (rem (+ (* seed 15625.7) 0.21137152) 1) 0.3171943)))
>
>
>

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community