# cards

## 370 days ago by calkin

r=[0,0,0,0,0] s=[0,0,0,0,0] t=[0,0,0,0,0]
r=(binomial(52,4)-binomial(48,4)+binomial(36,4)-binomial(32,4)+binomial(20,4)-binomial(16,4)+1)/binomial(52,4).n()
r=(binomial(48,4)-binomial(44,4)+binomial(32,4)-binomial(28,4)+binomial(16,4)-binomial(12,4))/binomial(52,4).n()
r=(binomial(44,4)-binomial(40,4)+binomial(28,4)-binomial(24,4)+binomial(12,4)-binomial(8,4))/binomial(52,4).n()
r=(binomial(40,4)-binomial(36,4)+binomial(24,4)-binomial(20,4)+binomial(8,4)-binomial(4,4))/binomial(52,4).n()
print(r)
 [0, 0.377194570135747, 0.279394219226152, 0.201809954751131, 0.141601255886970] [0, 0.377194570135747, 0.279394219226152, 0.201809954751131, 0.141601255886970]
def f(x): return(2/13. + 3*x/13.+ 5*x^2/13. + 3*x^3/13.)
(f(x)^4).expand()
 0.00283603515283078*x^12 + 0.0189069010188719*x^11 + 0.0586113931585029*x^10 + 0.116802632961031*x^9 + 0.171247505339449*x^8 + 0.194951157172368*x^7 + 0.176814537306117*x^6 + 0.129827386996254*x^5 + 0.0767830258044186*x^4 + 0.0361331886138441*x^3 + 0.0131648051538812*x^2 + 0.00336122684779945*x + 0.000560204474633241 0.00283603515283078*x^12 + 0.0189069010188719*x^11 + 0.0586113931585029*x^10 + 0.116802632961031*x^9 + 0.171247505339449*x^8 + 0.194951157172368*x^7 + 0.176814537306117*x^6 + 0.129827386996254*x^5 + 0.0767830258044186*x^4 + 0.0361331886138441*x^3 + 0.0131648051538812*x^2 + 0.00336122684779945*x + 0.000560204474633241
.00283603515283078+.112496061062288+.131858128216799+0.00283603515283078
 0.250026259584749 0.250026259584749
0.00283603515283078+0.17124750533944+0.0767830258044186+0.000560204474633241
 0.251426770771323 0.251426770771323
1 - 51./52*50/52*49/52
 0.111359239872554 0.111359239872554

Suppose we wish to indicate the position of the key card in the following manner:

Find the card of lowest rank, and use its suit to determine the position of the key card:

C=1, H=2, S=3, D=4.

Clearly if there are multiple cards of the same rank, this will skew the probabilities towards lower positions.  But by how much?

prob1=0 # Compute the the probability that the lowest rank is a single card for k in srange(1,13): prob1+= binomial(4*k,3) prob1= prob1*4/binomial(52,4) prob1=prob1.n() print(prob1)
 0.883553421368547 0.883553421368547
prob2=0 # Compute the the probability that the lowest rank appears twice for k in srange(1,13): prob2+= binomial(4*k,2) prob2= prob2*6/binomial(52,4) prob2=prob2.n() print prob2 print prob2
 0.111788715486194 0.111788715486194 0.111788715486194 0.111788715486194
prob3=0 # Compute the the probability that the lowest rank appears three times for k in srange(1,13): prob3+= binomial(4*k,1) prob3= prob3*4/binomial(52,4) prob3=prob3.n() print(prob3)
 0.00460984393757503 0.00460984393757503
prob4=13/binomial(52,4) print(prob4)
 1/20825 1/20825
print(prob2)
 0.111788715486194 0.111788715486194
s=prob1/4+prob2/2+prob3*3/4+prob4 # Probability that we signal a 1
s=prob1/4+prob2/3+prob3/4 #Probability we signal a 2
s=prob1/4+prob2/6 # Probability we signal a 3
s=prob1/4 # Probability we signal a 4
sum(s)
 1.00000000000000 1.00000000000000
print s[1:]
 [0.280288115246098, 0.259303721488595, 0.239519807923169, 0.220888355342137] [0.280288115246098, 0.259303721488595, 0.239519807923169, 0.220888355342137]

Suppose we wish to indicate the position of the key card in the following manner:

Find the card(s) of lowest rank, and use its suit to determine the position of the key card:

C=1, H=2, S=3, D=4.

Clearly if there are multiple cards of the same rank, this will skew the probabilities towards lower positions.  But by how much?

After some computation, we see that the probabilities of each position, two three digits, are as follows:

Pr(1) = 0.282

Pr(2) = 0.260

Pr(3) = 0.240

Pr(4) = 0.221

Notation: $r_i$ is the probability that the least rank is $i$ (mod 4).

$s_i$ is the probability that the earliest suit of the least rank is $i$

$t_i$ is the probability that least rank plus earliest suit of the least rank (mod 4) is $i$.

for i in srange(1,5): for j in srange(1,5): t[mod(i+j,4)]+=r[i]*s[j]
print t
 [0.250636532178667, 0.242257559394614, 0.252493298939301, 0.254612609487419, 0] [0.250636532178667, 0.242257559394614, 0.252493298939301, 0.254612609487419, 0]
t=t t=0
print t
 [0, 0.242257559394614, 0.252493298939301, 0.254612609487419, 0.250636532178667] [0, 0.242257559394614, 0.252493298939301, 0.254612609487419, 0.250636532178667]
show(r) show(s) show(t)
 \newcommand{\Bold}{\mathbf{#1}}\left[0, 0.377194570135747, 0.279394219226152, 0.201809954751131, 0.141601255886970\right] \newcommand{\Bold}{\mathbf{#1}}\left[0, 0.280288115246098, 0.259303721488595, 0.239519807923169, 0.220888355342137\right] \newcommand{\Bold}{\mathbf{#1}}\left[0, 0.242257559394614, 0.252493298939301, 0.254612609487419, 0.250636532178667\right]
4*binomial(13,4)+4*binomial(13,3)*3*13 + 6*binomial(13,2)*binomial(13,2) + 4*3*binomial(13,2)*13*13 + 13^4
 270725 270725
binomial(52,4)
 270725 270725

So it appears that these calculations are indeed correct:

4:hands with 4 of the same suit: $4 \binom{13}{4}$

3,1:  3 of one suit, 1 of another: $4 \binom{13}{3}3\binom{13}{1}$

2,2:  2 of one suit, 2 of another: $\binom{4}{2}\binom{13}{2}\binom{13}{2}$

2,1,1: 2 of one suit, 1 each of two other suits: $4 \binom{3}{2}\binom{13}{2}.13.13$

1,1,1,1: 1 of each suit: $13^4$

Probability of position 1:

$(4 \binom{13}{3}3\binom{13}{1}/3 + 4 \binom{3}{2}\binom{13}{2}.13.13/3 )/\binom{52}{4}$

(4*binomial(13,3)*3*13/3 + 4*3*binomial(13,2)*13*13/3)/binomial(52,4).n()
 0.249699879951981 0.249699879951981

Probability of position 2:

$(4 \binom{13}{3}3\binom{13}{1}/3+ \binom{4}{2}\binom{13}{2}\binom{13}{2)2/3+13^4)/\binom{52}{4}$

(4*binomial(13,3)*3*13/3 + 6*binomial(13,2)*binomial(13,2)*2/3 + 13^4)/binomial(52,4)
 5213/20825 5213/20825

Probability of position 4:

$$(4 \binom{13}{4} + 6 \binom{13}{2}\binom{13}{2}/3 +4.3.\binom{13}{2}.13.13/3 )/\binom{52}{4}$$

(4*binomial(13,4) + 6*binomial(13,2)*binomial(13,2)/3 + 4*3*binomial(13,2)*13*13/3)/binomial(52,4)
 5212/20825 5212/20825
n1=4*binomial(13,3)*3*13/3 + 4*3*binomial(13,2)*13*13/3 n2=4*binomial(13,3)*3*13/3 + 6*binomial(13,2)*binomial(13,2)*2/3 + 13^4 n3=4*binomial(13,3)*3*13/3 + 4*3*binomial(13,2)*13*13/3 n4=4*binomial(13,4) + 6*binomial(13,2)*binomial(13,2)/3 + 4*3*binomial(13,2)*13*13/3
print n1,n2,n3,n4
 67600 67769 67600 67756 67600 67769 67600 67756
(exp(pi*sqrt(163))).n(digits=27)
 2.62537412640768744000000000e17 2.62537412640768744000000000e17
exp(sqrt(163.)).n(prec=50)
 350510.28709706 350510.28709706
a=4
binomial(52,4)
 270725 270725
2^10
 1024 1024