HackerTrans
TopNewTrendsCommentsPastAskShowJobs

possiblywrong

no profile record

Submissions

Beware the "Natural" Quaternion

possiblywrong.wordpress.com
3 points·by possiblywrong·il y a 2 mois·0 comments

The Fisher-Yates shuffle is backward

possiblywrong.wordpress.com
65 points·by possiblywrong·il y a 7 mois·20 comments

Hierarchical field sort with string interning

nullprogram.com
1 points·by possiblywrong·il y a 10 mois·0 comments

comments

possiblywrong
·il y a 23 jours·discuss
The article deserves several clarifications:

> The deck has to be cut more or less in half before shuffling.

"More or less" is doing some heavy lifting here. The original GSR shuffling model cuts the deck at a point that is binomially distributed, so that for example about one-fifth of the time the cut may be at least as asymmetric as a 21-31 card split, which I think most would agree is nowhere near "the precision of a professional magician."

Also note that the theorem in the paper really focuses only on relaxing the cutting model; the model of subsequent interleaving of the resulting piles is the same, dropping a card from a pile with probability proportional to the size of the pile. (Equivalently but perhaps less intuitively, for the original GSR model with the binomial cut, imagine flipping a fair coin for each card in the deck, then "de-interleaving" by sliding the "heads" cards out, preserving their relative order, and placing that pile on top of the remaining "tails" cards.)

> But with that seventh shuffle, the deck suddenly tips into a highly unstructured state.

More accurately, the total variation distance from a uniform distribution first drops below 0.5 at seven shuffles[0]. The actual cutoff phenomenon's asymptotic result would suggest 3/2 lg n shuffles for a deck with n cards, which for n=52 would be closer to nine shuffles.

[0] https://possiblywrong.wordpress.com/2018/09/02/arbitrary-pre...
possiblywrong
·il y a 6 mois·discuss
Following is the closed form solution linked in the article (from a since-deleted Reddit comment):

    from functools import reduce

    def recurrence(ops, a0, n):
        def transform(x, op):
            return eval(repr(x) + op)
        ops = ops.split()
        m = reduce(transform, [op for op in ops if op[0] in ('*', '/')], 1)
        b = reduce(transform, ops, 0)
        for k in range(n + 1):
            print('Term 0: ', a0 * m ** k + b * (m ** k - 1) / (m - 1))
> This is really only interesting if a particular (potentially really large) term of the sequence is desired, as opposed to all terms up to a point. The key observation is that any sequence of the given set of operations reduces to a linear recurrence which has the given solution.
possiblywrong
·il y a 7 mois·discuss
It's interesting that the two forward versions of the algorithm were added to Wikipedia just a few months ago. (The OP article is from 2020.)