All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Probability
Card Shuffle Conclusion (Posted on 2022-05-20) Difficulty: 3 of 5
(I) Three identical packs of cards A, B and C, each being standard 52 card decks, are shuffled thoroughly. One card is picked from A and shuffled with B. Again, one card is picked from B and shuffled with C. Finally, one card is picked from C and shuffled with A.
The top card from A is now turned up and found to be the Jack of Hearts.
Determine the probability that the respective top cards in B and C will be the Queen of Hearts and the King of Hearts (in this order.)

(II) With all the other conditions of the problem remaining the same, suppose:
The top cards from A and B are turned up and are respectively found to be the Jack of Hearts and the Queen of Hearts.
Determine the probability that the top card from C will be the King of Hearts.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer-aided solution Comment 1 of 1
It's necessary to keep track of the possible states of the set of decks and their probabilities. After the first transfer, there are four possibilities, resulting from whether the card transferred was king of hearts, queen of hearts, jack of hearts, or some other card:

1/52         
[0, 1, 1, 49]
[2, 1, 1, 49]
[1, 1, 1, 49]
1/52
[1, 0, 1, 49]
[1, 2, 1, 49]
[1, 1, 1, 49]
1/52
[1, 1, 0, 49]
[1, 1, 2, 49]
[1, 1, 1, 49]
49/52        
[1, 1, 1, 48]
[1, 1, 1, 50]
[1, 1, 1, 49]
1            

The first line in each group is the probability of the state described below it, after the first transfer. In the 3-line state description, the first row is the state of pack A; the second row that of pack B; and the third row pack C. Each row represents the number of KH, QH, JH, other cards, respectively.

The last line is the sum of the probabilities. It's a check, and indeed produced the expected 1.

The set was produced by

p(1)=sym(1);
scen=[1 1 1 49
      1 1 1 49
      1 1 1 49];
scen=sym(scen);    
a={scen};   

% trans 1:
scen0=a{1};
for mover=1:4
  scen=scen0;
  p(mover)=scen(1,mover)/sym(sum(scen(1,:)));
  scen(1,mover)=scen(1,mover)-1;
  scen(2,mover)=scen(2,mover)+1;
  newa{mover}=scen;
  disp(p(mover))
  disp(newa{mover})
end

disp(sum(p))


The program continued by producing a set of states and their probabilities after the second transfer:

a=newa;
newa={};
newp=sym.empty;

% trans 2:

for scenario=1:length(a)
  p0=p(scenario);
  scen0=a{scenario};
  for mover = 1:4
    scen=scen0;
    newp(end+1)=sym(p0*scen0(2,mover)/sym(sum(scen0(2,:))));
    scen(2,mover)=scen(2,mover)-1;
    scen(3,mover)=scen(3,mover)+1;
    newa{end+1}=scen;
    disp(newp(end))
    disp(newa{end})
  end
end
p=newp;
a=newa;

disp(sum(newp))

Since there were four previously possible states, and four possibilities in each case, there were 16 new possible states with their probabilities:

1/1378
[0, 1, 1, 49]
[1, 1, 1, 49]
[2, 1, 1, 49]
1/2756
[0, 1, 1, 49]
[2, 0, 1, 49]
[1, 2, 1, 49]
1/2756
[0, 1, 1, 49]
[2, 1, 0, 49]
[1, 1, 2, 49]
49/2756
[0, 1, 1, 49]
[2, 1, 1, 48]
[1, 1, 1, 50]
1/2756
[1, 0, 1, 49]
[0, 2, 1, 49]
[2, 1, 1, 49]
1/1378
[1, 0, 1, 49]
[1, 1, 1, 49]
[1, 2, 1, 49]
1/2756
[1, 0, 1, 49]
[1, 2, 0, 49]
[1, 1, 2, 49]
49/2756
[1, 0, 1, 49]
[1, 2, 1, 48]
[1, 1, 1, 50]
1/2756
[1, 1, 0, 49]
[0, 1, 2, 49]
[2, 1, 1, 49]
1/2756
[1, 1, 0, 49]
[1, 0, 2, 49]
[1, 2, 1, 49]
1/1378
[1, 1, 0, 49]
[1, 1, 1, 49]
[1, 1, 2, 49]
49/2756
[1, 1, 0, 49]
[1, 1, 2, 48]
[1, 1, 1, 50]
49/2756
[1, 1, 1, 48]
[0, 1, 1, 50]
[2, 1, 1, 49]
49/2756
[1, 1, 1, 48]
[1, 0, 1, 50]
[1, 2, 1, 49]
49/2756
[1, 1, 1, 48]
[1, 1, 0, 50]
[1, 1, 2, 49]
1225/1378
[1, 1, 1, 48]
[1, 1, 1, 49]
[1, 1, 1, 50]
1

Again the total probabilities, as a check, was 1.

A third, similar, transition was made for the third transfer:

newa={};
newp=sym.empty;

% trans 3:

for scenario=1:length(a)
  p0=p(scenario);
  scen0=a{scenario};
  for mover = 1:4
    scen=scen0;
    newp(end+1)=sym(p0*scen0(3,mover)/sym(sum(scen0(3,:))));
    scen(3,mover)=scen(3,mover)-1;
    scen(1,mover)=scen(1,mover)+1;
    newa{end+1}=scen;
    disp(newp(end))
    disp(newa{end})
  end
end
p=newp;
a=newa;

There are too many to show, but the list begins

1/36517
[1, 1, 1, 49]
[1, 1, 1, 49]
[1, 1, 1, 49]
1/73034
[0, 2, 1, 49]
[1, 1, 1, 49]
[2, 0, 1, 49]
1/73034
[0, 1, 2, 49]
[1, 1, 1, 49]
[2, 1, 0, 49]
49/73034
[0, 1, 1, 50]
[1, 1, 1, 49]
[2, 1, 1, 48]
1/146068
[1, 1, 1, 49]
[2, 0, 1, 49]
[0, 2, 1, 49]
1/73034
[0, 2, 1, 49]
[2, 0, 1, 49]
[1, 1, 1, 49]


It did include the combination of the probabilities of a handful of states that arrived via different routes but had the same makeup:

for i=1:length(a)
  for j=i+1:length(a)
     if isequal(a{i},a{j})
       disp([i j])
       a={a{1:j-1} a{j+1:end}};
       p(i)=p(i)+p(j);
       p(j)=[];
     end
     if j>=length(a)
       break
     end
  end
  if i>=length(a)
    break
  end
end

The results are the same with or without this combination of identical states.

The a priori probability that the JH would have been chosen from A is the total of the probabilities that each of the given states that had Jacks were the actual case multiplied by the probability that a Jack would be chosen from that state given that the state was in fact that one.

Each scenario's probability of being the case is multiplied by the probability of that state producing a JH from A, a QH from B and a KH from C. The latter is divided by the former to produce

part (I) answer:

36557/98741968
   ~=   0.000370227581447435
      
part (II) answer:

Similar calculations are done here except that in each scenario (state)  the probability of the state is multiplied by the probability of QH and JH for contribution to the denominator, which is thereby smaller:

36557/1899586
   ~=     0.0192447196389108
   

For the above:

% part (i)
ctJ=sym(0); ctJQK=sym(0);
for i=1:length(a)
  scen=a{i};
  if scen(1,3)>0
    ctJ=ctJ+p(i)*scen(1,3);
 %   disp([p(i)*scen(1,3)/52])
    if scen(2,2)>0 && scen(3,1)>0
      ctJQK=ctJQK+p(i)*scen(1,3)*scen(2,2)*scen(3,1)/(52^2);
    end
  end
end
disp(ctJQK/ctJ);
disp(eval(ctJQK/ctJ));

% part (ii)
ctJQ=sym(0);
for i=1:length(a)
  scen=a{i};
  if scen(1,3)>0 && scen(2,2)>0
    ctJQ=ctJQ+p(i)*scen(1,3)*scen(2,2)/52;
  end
end
disp(ctJQK/ctJQ);
disp(eval(ctJQK/ctJQ));



Simulation:
   
  succ1=0; succ2=0;
  AJHCt=0; AJHBQHCt=0;

for trial=1:100000000
  % consider 50, 51, and 52 being JH, QH, KH respectively
  deckA=1:52; deckB=1:52; deckC=1:52;
  
  r=randi(52);
  deckB=[deckB deckA(r)]; deckA(r)=[];
    
  r=randi(length(deckB));
  deckC=[deckC deckB(r)]; deckB(r)=[];

  r=randi(length(deckC));
  deckA=[deckA deckC(r)]; deckC(r)=[];
  
  r=randi(length(deckA));
  if deckA(r)==50
    AJH=true;
  else
    AJH=false;
  end  
  
  r=randi(length(deckB));
  if deckB(r)==51
    BQH=true;
  else
    BQH=false;
  end
  
  r=randi(length(deckC));
  if deckC(r)==52
    CKH=true;
  else
    CKH=false;
  end
  
  if AJH
    AJHCt=AJHCt+1;
    if BQH && CKH
      succ1=succ1+1;
    end
  end
  
  if AJH && BQH
    AJHBQHCt=AJHBQHCt+1;
    if   CKH
      succ2=succ2+1;
    end
  end  
end
disp([succ1 AJHCt succ2 AJHBQHCt])
disp([succ1/AJHCt succ2/AJHBQHCt])   
   
>> cardShuffleConclusionSim
         693     1923369         693       36785
      0.000360305276834554        0.0188392007611798   
      
>> cardShuffleConclusionSim
         701     1921248         701       37322
      0.000364867003114642        0.0187824875408606
      
>> cardShuffleConclusionSim
         665     1922356         665       37010
      0.000345929682119233        0.0179681167252094
      
>> cardShuffleConclusionSim
         706     1923567         706       37383
      0.000367026466975156        0.0188855897065511     
      
>> cardShuffleConclusionSim
         688     1921679         688       36969
      0.000358020252081643        0.0186101869133598      
      
      
This seemed to be consistently lower than the calculated probabilities, so I wondered whether the random number generator was faulty, and I tried a couple of things.

In all the instances, the newly placed card in the receiving deck had been placed at the end. This should have had no effect on the outcome as subsequent selection from that deck, either for placement onto the next deck or for checking the "top" card at the end, was done randomly. But in changing two of the transfers to the beginning of the vector representing the deck, differing results occurred:
      
>> cardShuffleConclusionSim
         748     1924587         748       36898
      0.000388654812694879        0.0202721014689143   
      
Actual shuffling was done next, via, for example

deckB=deckB(randperm(length(deckB)));

and a test (now taking twice as long--an hour) resulted in
      
         705     1925266         705       37262
      0.000366183166378049        0.0189200794374966      
      
so the RNG does seem not to be really good enough for 100 million trials, and I would trust my computed probabilities.         

Edited on May 20, 2022, 2:02 pm
  Posted by Charlie on 2022-05-20 14:01:31

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (10)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information