Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
sci.math.*
»
sci.math
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
Card shuffling
Replies:
7
Last Post:
Jul 31, 2012 10:33 AM




Re: Card shuffling
Posted:
Jul 31, 2012 9:25 AM


Many thanks to all who have followed up. As I wrote in a 2nd post, I have done some experiments. I found a presumably not too bad, though I guess yet suboptimal, scheme as follow:
Let n be the length of the list to be permuted and kn be a point of division of the list into two sections. One applies riffle shuffle to each section and then reverse the ordering of the whole.
It seems to me that, if kn is (randomly chosen and) located in the middle half of the list, then the permutation effected is a sufficiently "random" one in some sense.
Perhaps someone could give hints on improvements or provide a similar but better scheme. For those who like to try out mine, I am attaching a Python code below.
M. K. Shen

def makecards(n): cards=[] for i in range(n): cards+=[i] return(cards)
def riffle(cards,n): newcards=[] nh=n//2 for i in range(nh): newcards=newcards+[cards[nh+i]]+[cards[i]] if nh*2<n: newcards+=[cards[n1]] return(newcards)
def newshuffle(cards,kn,n): newcards=riffle(cards[0:kn],kn)+riffle(cards[kn:n],nkn) newcards.reverse() return(newcards)
# example:
n=52 cards=makecards(n) kn=18 newcards=newshuffle(cards,kn,n) print(newcards)



