Live data from Hacker News

Shuffling

datagenetics.com

1–10 of 17 posts

Re: Shuffling

#2
This is great, I never had intuitive understanding of why the naive shuffle was bad other than a vague notion of the fallibility of pseudo-random number generators. Seeing a math equation is one thing but seeing a tree of all possible outcomes visualized in front of you not only makes the bias blatant, but also makes it obvious why the bias is occurring.

Re: Shuffling

#3

This is great, I never had intuitive understanding of why the naive shuffle was bad other than a vague notion of the fallibility of pseudo-random number generators. Seeing a math equation is one thing but seeing a tree of all possible outcomes visualized in front of you not only makes the bias blatant, but also makes it obvious why the bias is occurring.

Thanks for kind comments.

Re: Shuffling

#6
post #4

What motivated that choice of psudocode? I found it very hard to read.

It's looks very close to Visual Basic to me ... :)

Yes, it is VB6.

I did actually put quite a bit of thought into how I was going to put in the code samples. I elected to use BASIC like syntax because IMHO, this is close to as common denominator as possible and most universally understood (this is not an invite to start a flame war!)

I also elected to start by arrays at 1, rather than 0. The purest in my wanted to use zero, but to make it more universally understood, I elected to use one (because it also relates to the real world and card #1). I think more people will understand it this way.

The other thing I almost did not do (but changed my mind at the last minute), was to in-line the swap function and enumerate all three steps. I almost wrote it with Swap(i,s) function instead. Half of me thinks using a function is easier to understand, the other half likes the in-line for explaining it.

It's not as if the logic is very hard, there's one loop.

I'm curious what others think. Was it hard to understand? I'm always keen to learn more. Could I have explained it easier with the changes above?

Re: Shuffling

#7
Here is a demo of shuffling using a combination of Hindu & Riffle shuffle http://karmadude.github.io/CardShuffler/

I heard someone say once that we have to shuffle a deck of cards 7 times to get a good shuffle. This demo was setup to try to simulate how we shuffle cards, and turns out shuffling around 5 times gives a pretty good shuffle.

Re: Shuffling

#8

Earlier quoted context omitted.

It's looks very close to Visual Basic to me ... :)

Yes, it is VB6. I did actually put quite a bit of thought into how I was going to put in the code samples. I elected to use BASIC like syntax because IMHO, this is close to as common denominator as possible and most universally understood (this is not an invite to start a flame war!) I also elected to start by arrays at 1, rather than 0. The purest in my wanted to use zero, but to make it more universally understood,…

numbering should start at 0. http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...

He also made comments about using Basic. Seems you made the wrong choices...

Re: Shuffling

#9

Here is a demo of shuffling using a combination of Hindu & Riffle shuffle http://karmadude.github.io/CardShuffler/ I heard someone say once that we have to shuffle a deck of cards 7 times to get a good shuffle. This demo was setup to try to simulate how we shuffle cards, and turns out shuffling around 5 times gives a pretty good shuffle.

To paraphrase, 7 is reasonably able, 14 is guaranteed.

Knuth cites this in TAOVP vol 2, from Aldous And Diaconis, AMM 1986, pp 333-348.

Re: Shuffling

#10
I love the idea of combining this with the idea of proving code.

Like, "how can I prove my approach 'shuffles' an array?" ... I mean, just because it looks right... doesn't mean it is.

Post reply on HN