Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Find Function to fit data - Card shuffle

  1. Oct 17, 2013 #1
    Hello,
    I had a chat with a person at work and we were discussing a card shuffle and what governed its behaviour. Here's the shuffle rules.
    Have to use an even number of cards
    Take top and bottom card and make new pile
    the next top and bottom card go below the new pile

    Here's an example of a shuffle with 4 cards
    1,2,3,4 <-- Original
    1,4,2,3 <-- 1st Shuffle
    1,3,4,2 <-- 2nd Shuffle
    1,2,3,4 <-- 3rd Shuffle

    As you can see on the 3rd shuffle, the cards return to their original order. We are trying to predict, given an even number of cards, how many shuffles it will take for the cards to return to their original order.
    I wrote a VB Console application and calculated for all even numbers between 2 up to 32768. I graphed the data on a scatter plot and found that there's an upper and lower boundary that all the data exists in and there's other patterns as well.
    The upper boundary is given by: y=x-1
    The lower boundary is given by: y= (log2 x) -1

    But we weren't able to find a single function that was able to predict what the number of shuffles would be, given an even number of cards. Any ideas on how to solve this?

    I've attached 2 files:
    A tab delimited text file containing data for number of cards/number of shuffles for all even numbers from 2 up to 32768
    The source (in visual basic - Console program) for the program I wrote to calculate values (to verify that I didn't screw up in the data generation)

    Cheers,
    Routaran
     

    Attached Files:

  2. jcsd
  3. Oct 17, 2013 #2
    If I understand correctly, you take input [tex]1,2,...,x-1,x[/tex] and give output [tex]1,x, 2,...,x-1.[/tex] If that's the case, it seems like your upper-boundary should always be how long it takes, i.e. [itex]x-1[/itex]. Indeed, you're just leaving the first card where it is and cycling the other [itex]x-1[/itex].
     
  4. Oct 17, 2013 #3
    No, this doesn't apply to all possible numbers of cards. In my example i used 4 cards and it appears this way. If I use 10 cards and do the shuffle, it no longer follows this pattern.
    10 card example:
    Code (Text):

    1   2   3   4   5   6   7   8   9   10 <-- Original
    1   10  2   9   3   8   4   7   5   6  <-- 1st Shuffle
    1   6   10  5   2   7   9   4   3   8  <-- 2nd Shuffle
    1   8   6   3   10  4   5   9   2   7  <-- 3rd Shuffle
    1   7   8   2   6   9   3   5   10  4  <-- 4th Shuffle
    1   4   7   10  8   5   2   3   6   9  <-- 5th Shuffle
    1   9   4   6   7   3   10  2   8   5  <-- 6th Shuffle
    1   5   9   8   4   2   6   10  7   3  <-- 7th Shuffle
    1   3   5   7   9   10  8   6   4   2  <-- 8th Shuffle
    1   2   3   4   5   6   7   8   9   10 <-- 9th Shuffle

     
     
  5. Oct 18, 2013 #4
    Okay, cool. That clarifies it.

    So if [itex]x=2n[/itex], your shuffle takes [tex]t_1,...,t_n,b_n,...,b_1[/tex] to [tex]t_1,b_1,...,t_n,b_n.[/tex]
     
  6. Oct 18, 2013 #5
    yes, this appears represents each successive shuffle correctly for any number of n

    How do I go from this general representation to figuring out how many shuffles it will take to get the original state for any given n?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Find Function to fit data - Card shuffle
Loading...