Re: Shuffle, Shuffle, what's the Ruffle?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Al, it's generous gesture. Let us forget it, if you can. I can.

Thanks. jiri

----- Original Message -----
From: "Al Getz" <Xaxo at aol.com>
To: "EUforum" <EUforum at topica.com>
Sent: Saturday, March 10, 2001 6:55 PM
Subject: Shuffle, Shuffle, what's the Ruffle?


> For Jiri and others interested in shuffle algorithms:
>
> Hi there again Jiri,
>
>   Im happy to hear you are so emphatic about the coding
> of various algorithms, most people i meet dont care
> one way or the other.  It is nice to find people who care
> about what they write and modify and such.
>
>   Sorry for the misunderstanding, but i wasnt trying
> to correct you, but rather simply posting another
> solution, as i often do.
> I was a little surprised though, as ive found your particular
> coding to be of value to me, both in application and theory.
> Your algorithm 'remove()' was very efficient, and when i asked
> you to elaborate on it, you posted exactly what i was looking
> for!  Its mostly out of that kind of respect for your programming
> technique that i decided to look into this a little further.
>
> Also, i always felt this forum was a good way to hash out
> different approaches to code anyway, hearing different opinions
> and adding them up.  Several minds working on the same problem
> is much like several cpu's in a computer, gets the work done
> N times as fast.
>
> Well, as it turns out, wasnt that code you originally posted
> exactly what i posted over two years ago in response to
> questions regarding shuffling?  That was an
> algorithm written in QBasic by a twelve year old kid if
> i remember right.  I also remember you getting peeved
> because of all the talk about shuffling?  smile
>
> Granted i should have looked it up before posting, as i
> remembered what i considered near optimum code for
> a shuffle function incorrectly -- im too often in a hurry,
> and couldnt even find time for one of my usual salutations.
> The one i had considered best was actually the one you originally
> posted as well, but certainly not because the original is so much
> faster, but rather because its slightly more statistically balanced
> for a great number of shuffles.  Its not much, but it is better
> for apps that will shuffle a great number of times.
>
> It's to that end that i can therefore only offer a very slight
> improvement to the original code, which turns out to be
> just as statistically balanced as the first:
>
> function shuffle_Al(sequence s)
>      object temp
>      integer j
>
>      for i = 2 to length(s) do
>          j = rand(i)
>          temp = s[j]
>          s[j] = s[i]
>          s[i] = temp
>      end for
>      return s
> end function
>
>
> Perhaps this is the last word on shuffle?  Perhaps not.  In any
case,
> im sure there will be more newcommers to the list who are looking
> for a shuffle algorithm--perhaps that suggestion to start a
> standard library could start right here?
>
> Good luck with your future programming,
> --Al
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu