comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Random ordering
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Random ordering [message #35528] Tue, 24 June 2003 13:55 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
David Fanning wrote:
>
> trouble writes:
>
>> Stuck again. I want to create an integer 1D array from 0 to n (n ~
>> 100) so that the numbers are in jumbled up order so that "nearby"
>> numbers, eg. ABS(difference) < 3, are "far" apart. I think there must
>> be a nice way using MOD rather than bludging it with RANDOMU. Anyone
>> got any suggestions?

Any algorithm than uses MOD rather than RANDOMU must necessarily be
non-random, so I'm assuming a completely regular result is acceptable?
By "jumbled up" do you mean a permutation of indgen(n), as opposed to a
sequence that might contain repeats?
If so, then try

jumble = (jumble_increment(n,m)*INDGEN(n)) MOD n

for m=3, which is the limit you've placed on ABS(difference).
jumble_increment(n,m) is the integer between 0 and n which is nearest to
n/m, which does NOT divide 'n'. The algorithm for jumble_increment() is
left as an excersize for the reader (I'm being lazy).
[Message index]
 
Read Message
Read Message
Previous Topic: Random ordering
Next Topic: How to do nested objects??

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 15:22:47 PDT 2025

Total time taken to generate the page: 1.28142 seconds