Re: Random Numbers fasters than the osax
Re: Random Numbers fasters than the osax
- Subject: Re: Random Numbers fasters than the osax
- From: email@hidden (Michael Sullivan)
- Date: Mon, 1 Apr 2002 16:42:35 -0500
- Organization: Society for the Incurably Pompous
Arthur J Knapp writes:
>
> From: Emmanuel <email@hidden>
>
> At 1:21 AM +0200 30/3/02, Arthur J Knapp wrote:
>
>>
>
>> I would really appreciate it if someone could point me in the
>
>> direction of some simple pseudo code for RNGs, (as opposed to
>
>> platform-optimized implementations or complex mathematical theses).
>
> I'm surely missing something, but what's wrong with the suggestion I
>
> presented 3 days ago?
>
>> set theNextRandomNumber to (thePreviousOne + BigBigPrime) mod (BigPrime)
>
>
>> where BigPrime is any big prime number, and BigBigPrime a still bigger one.
>
Nothing is wrong with this, Emmanual, it's great. :)
Actually, it's problematic for reasons I've brought up in another post.
Well, it's usable if a *very* dirty sequence is acceptable, which is
probably true a lot of the time.
>
I am just aware that there are many different algorithms for generating
>
random numbers, and yet it is difficult to find simple resources for
>
these techniques that do not require a doctorate in calculus. ;-)
Number Theory is what you're looking for, actually.
>
> (if you're looking for integer random numbers, then BigPrime must be
>
> something like your range of values - not a prime number then)
>
Right, any range can be found with this type of formula:
>
(R mod M) + N
>
where R is a random number, M is the upper bounds, and N is the lower
>
bounds.
I think you mean:
(R mod (M - N + 1)) + N
Michael
--
Michael Sullivan
Business Card Express of CT Thermographers to the Trade
Cheshire, CT email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.