I've had an error report on trting to send this to allstat. Whether
it was because of the attached Word document I do not know, but to
play safe only the text file is attached here.
Again, my thanks for all who contributed and apologies to any not
selected for the list of main contributions (many people had similar
approaches).
I will not be posting any more contributions, though I still welcome
hearing from anyone with an exact, elegant answer to this problem.
Regards
Miland Joshi
You may find it simpler to use the following email address in replying:
[log in to unmask]
Contributions on ‘Probability Challenge’
The problem was:
Have one pack of cards (shuffled), ask a person to name any two types
of card, eg. jack and two (suits not included). Then just go
through the pack of cards placing the cards face up on the table and
aparently there's a good chance that these cards will turn up next to
each other.
Is this true?
My original approximate answer was:
Suppose the numbers specified are different, say 7
and 3. Suppose for simplicity that apart from the four 3's, of the 48
cards laid out the 7s are not at the ends, and have at least two
spaces between them. Then there are 49 possible 'slots' in which the
3's can go, and of these 8 will result in a 7 and a 3 being next to
each other. Hence the probability that this will not happen is
((41/49)^4) = 0.49. Hence, bearing in mind the simplifications, the
chance that we will get a 3 and a 7 together is about even.
>From Magnus Peterson
A Approximate solution (rather like yours I believe).
Let the cards be dealt out after shuffling in a straight line. Then there are
51 gaps between pairs of cards, and each may lie between a desirable pair or
not. Hence the number of desirable pairs X[i] associated with the ith
gap is either 0 or 1, and the expected value of X[i] is just Pr(X[i]=1), which
by elementary probability theory is
Pr(Card on left is A)*Pr(Card on right is Bcard on left is A) +
Pr(Card on left is B)*Pr(Card on right is Acard on left is B)
=(4/52)*(4/51)+(4/52)*(4/51) = 8/(13*51).
But the expected number of desirable pairs in the whole deal (D say) is then
obviously
E(D) = E(X[1])+E(X[2])+...+E(X[51]) = 8/13 = 0.6154 approx.
However also E(D) = 0*p[0]+1*p[1]+...+7*p[7]
where p[i] is the probability that there are i desirable pairs in all in the
deal. Hence we can obtain bounds on p[0] by assuming (falsely in each case)
(1) that p[2]=p[3]=...=p[7]=0, yielding p[0]=18/13=5/13=0.3846 approx
(too small)
or
(2) that p[1]=p[2]=...=p[6]=0, yielding p[0]=18/(13*7)=0.912 (much too big).
B Exact solution
My solution here depends on the result that with the pack in any FIXED order
if the cards are dealt out so that when k cards have already been placed
and then the (k+1)th is located with equal probability in any one of the
(k+1) available positions between those already dealt (including the two end
positions) then each of the 52! deals is equally likely to occur.
Let then the pack be organised so that the 8 "desirable" cards are at the top,
and then let the deal proceed. After the first eight cards have been dealt
there will just be the eight desirable cards on the table in one of
(8 choose 4) equiprobable distinguishable arrangements with the numbers of
desirable pairs at that stage having the following probabilities (as is
easily verified by simple enumeration):
No prs 0 1 2 3 4 5 6 7
Probs 0 1/35 3/35 9/35 9/35 9/35 3/35 1/35.
Thus the Probability Generating Function for the distribution of the number
of desirable pairs at this stage is
f[8](s)= s+3s^2+9s^3+9s^4+9s^5+3s^6+s^7.
Let f[k](s) be the PGF for this number after k cards (8<k<53). Since when
any other card is dealt it will either split a desirable pair with probability
r/k given that there are r desirable pairs in the previous stage, or fail
to do
so with probability 1r/k, it is "easy to see" that
f[k](s)=((1s)*df[k1](s)/ds+k*f[k1](s))/k
or equivalently that there is a recursion among the corresponding coefficients
(probabilities) of the form
p[k,r]=[(kr)*p[k1,r]+(r+1)*p[k1,r+1]]/k.
A little work either with a computer algebra package (for the GF) or a
spreadsheet (for the recursion) then yields the answers
p[52,0]=0.513721 p[52,1]=0.371932 p[52,2]=0.100492
p[52,3]=0.01298 p[52,4]=0.000848 p[52,5]=2.72E05
p[52,6]=3.81E07 p[52,7]=1.71E09.
Hence your original approximation was close to the truth.
I send as an attachment to this message the Excel spreadsheet which I used to
calculate the numbers above. (next page)
>From Kenneth Butler:
I got an answer just over 0.5 (actually 0.514) of failing to get any 3's
and 7's adjacent, and thus a probability of just under 0.5 of "success" 
very close to even, though.
Your approximation certainly takes care of much the commonest case, where
none of the 7's are next to each other. I think it is unnecessary to
worry about ends, because your 49 "slots" include the ones outside the
current outermost cards. Also, if you have the 7's separated only by one
of the 44 "plain cards", that still gives you two places to put a 3 next
to each 7.
My failure probability is about 2% higher than yours for two reasons:
1. I was thinking of placing the 3's one at a time. So, when you're
placing the 1st 3, you have 49 slots available, with 8 to avoid for a
probability of 41/49, as you said, but the first 3 has to go somewhere,
and so when you come to the second one, you now have 50 slots available
and 8 to avoid (assuming the 7's are separated). This makes the
probability of failure (41/49)(42/50)(43/51)(44/52)=0.501.
2. I calculated that the four 7's will be separated about 76.5% of the
time. It could be that some of the 7's are next to each other, but the
only case that is at all likely (it happens about 21.9% of the time) is
that you get one pair of adjacent 7's and the other two separated from
each other and this pair. This gives you only 7 slots to avoid, since the
pair only gives three (before it, after it, or between the two 7's), which
makes it a bit easier to fail: (42/49)(43/50)(44/51)(45/52)=0.550 by my
reckoning.
If you assume that all the cases with any neighbouring 7's have a pair of
7's and two singles, the approximate probability of failure is
(0.501)(0.765)+(0.550)(10.765)=0.5125
which is very close to my accurate answer.
I then went on and figured the probabilities of all the arrangements of
7's, and the probability of not getting any 3's next to them. The more
bunchedup the 7's, the fewer the slots that have to be avoided (down to 5
when the 7's are in a group of four), but this is very nearly irrelevant
considering that the other possibilities (2 pairs of 7's, 3 7's and one
odd one, 4 7's) are all very unlikely. (The chance of 3 adjacent 7's and
one odd one is about 1%.)
(While I was working this out, I had a simulation running, which yielded
4813 successes and 5187 failures out of 10000 trials, which is entirely
consistent with my calculations.)
It's rather a shame that the probability of getting the cards to come out
adjacent is just less than 50%, rather than just more: you, as a card
shark, would love to be able to say "Shuffle these cards, and name me two
ranks, such as 3 and 7. I bet you I can get a 3 next to a 7 when I deal
the cards out". But this is a losing bet. Too bad.
>From John Whittington:
I'm a great empiricist, so
just ran a quick simulation in SAS. As you'll see from the following log, I
got 485,546 successes out of 1,000,000 random placements of the four 3's and
four 7's  pretty close to your 0.49 answer:
179 data _null_ ;
180 retain count total success 0 ;
181 array deck(*) c1c52 ;
182 do trial = 1 to 1000000 ;
183 do i = 1 to dim(deck) ; deck(i) = . ; end ;
184 count = 0 ;
185 do until (count = 8) ;
186 place = ceil(ranuni(3456357)*52) ;
187 if deck(place) = . then do ;
188 count = count + 1 ;
189 if count <4.5 then deck(place) = 7 ; else deck(place) = 3 ;
190 end ;
191 end ;
192 do i = 1 to 51 ;
193 found = 0 ;
194 if (deck(i) = 3 and deck(i+1) = 7) or (deck(i) = 7 and
deck(i+1) = 3) then do ;
195 success = success + 1 ; found = 1 ;
196 end ;
197 if found = 1 then leave ;
198 end ;
199 total = total + 1 ;
200 end ;
201 put total= success= ;
202 run ;
TOTAL=1000000 SUCCESS=485546
NOTE: The DATA statement used 4 minutes 17.53 seconds.
>From Ian Saunders:
Version 1:
There are only 78 possible pairs, including 'identical' pairs
(Ace,Ace) etc. So in 51 tries there's a pretty good chance of getting the
chosen one.
There's a bit of sleight of hand in the above. The following is more
careful, but longer!
Version 2 (N.B. this is representative of a number of contributors who have suggested this approach,
though a list is not given here):
There are 13*13 = 169 possible ordered pairs of cards. Assuming
that the chosen pair has two distinct cards, there are 2 ways for it to
occur, so a random choice of a pair has probability 167/169 of NOT being the
chosen pair.
In laying out 52 cards you have 51 goes at picking the chosen pair. On the
large and untrue assumption that the pairs are independent, the probability
of missing it on all 51 is (167/169)^51 = 54.4%. Since the dependence
reduces the number of possible repeats of a pair, the number of distinct
pairs in a real deal will be greater than that for random generation of 51
pairs, so the probability of getting the chosen pair will be greater than
100%54.4% = 45.6%.
>From David Lovell:
With regards to your card problem, call the two types of cards A and B.
Deal the cards in a circle (this will give you an approximate answer
without having to deal with any "edge effects").
Go to the first A card (A1)
P(left(A1) != B) = (51  4) / 51
P(right(A1) != B  left(A1) != B) = (50  4) / 50
Now go to A2
P(left(A2) != B  left(A1) != B && right(A1) != B) = (49  4) / 49
etc...
Thus
P(left(A1) != B && right(A1) != B && left(A2) != B && ...) =
47 x 46 x 45 x 44 x 43 x 42 x 41 x 40

51 x 50 x 49 x 48 x 47 x 46 x 45 x 44
which is 0.494.
So the probability of at least one instance of adjacent A's and B's
will be just over a half.
>From Peter Donnelly:
We are trying to calculate the probability that none of the
8 slots next to the 7's contained a 3. There are 48 choose 8 ways of
assigning cards to these slots, with no restrictions. There are 44
choose 8 ways of filling the slots if we are not allowed to use any of
the 3's.
Thus the probability required is 1(44C8/48C8) = 0.530
