Page 115 #19

A gin hand consists of 10 cards from a deck of 52 cards. Find the probability that a gin hand has a) all 10 cards of the same suit. b) exactly 4 cards in one suit and 3 in two other suits. c) a 4, 3, 2, 1, distribution of suits.

a) all 10 cards of the same suit

\[ \text{Ways to choose 10 cards: } {52\choose 10}\\ \text{Ways to choose ten of the same suit: } 4 \cdot {13\choose 10}\\ \frac{4 \cdot {13\choose10}}{52\choose10} \approx 0.000000072 \]

(4*choose(13,10))/choose(52,10)
## [1] 7.231342e-08

b) exactly 4 cards in one suit and 3 in two other suits.

\[ \text{Ways to choose 10 cards: } {52\choose 10}\\ \text{Ways to select exactly 4 cards in one suit and 3 in two other suits: } {13\choose 4}{4\choose 1}{3\choose 2}{13\choose 3}{13\choose 3}\\ \frac{{13\choose 4}{4\choose 1}{3\choose 2}{13\choose 3}{13\choose 3}}{52\choose 10} \approx 0.044362112 \]

(choose(13,4)*choose(4,1)*choose(3,2)*choose(13,3)*choose(13,3))/choose(52,10)
## [1] 0.04436211

c) a 4, 3, 2, 1, distribution of suits.

\[ \text{Ways to choose 10 cards: } {52\choose 10}\\ \text{Ways to choose a 4,3,2,1 disribution of suits: } 4 \cdot {13\choose4} \cdot 3 \cdot {13\choose 3} \cdot 2 \cdot {13\choose 2} \cdot 1 \cdot {13\choose 1}\\ \frac{4 \cdot {13\choose4} \cdot 3 \cdot {13\choose 3} \cdot 2 \cdot {13\choose 2} \cdot 1 \cdot {13\choose 1}}{52\choose 10} \approx 0.3145677 \]

(4*choose(13,4)*3*choose(13,3)*2*choose(13,2)*1*choose(13,1))/choose(52,10)
## [1] 0.3145677

Page 156 #39

Assume that the random variables X and Y have the joint distribution given in Table 4.6.

  1. WhatisP(X≥1andY ≤0)?

  2. What is the conditional probability that Y ≤ 0 given that X = 2?

  3. Are X and Y independent?

  4. What is the distribution of Z = XY ?

I summarized the joint distribution below. To see the original table, check page 156 for Table 4.6.

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
xy_df <- data.frame(
  X = as.integer(c(-1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2)),
  Y = as.integer(c(-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2)),
  Probability = as.numeric(c(0, 1/18, 0, 1/12, 1/36, 0, 1/36, 0, 1/6, 1/18, 1/6, 1/12, 1/12, 0, 1/12, 1/6)))

print(xy_df)
##     X  Y Probability
## 1  -1 -1  0.00000000
## 2  -1  0  0.05555556
## 3  -1  1  0.00000000
## 4  -1  2  0.08333333
## 5   0 -1  0.02777778
## 6   0  0  0.00000000
## 7   0  1  0.02777778
## 8   0  2  0.00000000
## 9   1 -1  0.16666667
## 10  1  0  0.05555556
## 11  1  1  0.16666667
## 12  1  2  0.08333333
## 13  2 -1  0.08333333
## 14  2  0  0.00000000
## 15  2  1  0.08333333
## 16  2  2  0.16666667

a) What is \(P(X\geq 1 \text{ & } Y \leq 0)\)?

\[ P(X\geq 1 \text{&} Y \leq 0) = 0 + 1/6 + 1/12 + 1/18 = 11/36 \approx0.30555 \]

prob_a <- xy_df %>%
  filter(X>=1 & Y<=0) 

print(prob_a)
##   X  Y Probability
## 1 1 -1  0.16666667
## 2 1  0  0.05555556
## 3 2 -1  0.08333333
## 4 2  0  0.00000000
sum(prob_a$Probability)
## [1] 0.3055556

b) What is the conditional probability that \(Y ≤ 0\) given that \(X = 2\)?

\[ P(Y\leq 0 | X = 2) = \frac{P(Y\leq 2 \cap X=2)}{P(X=2)}\\ =\frac{1/12 + 0}{1/12 + 0 + 1/12 + 1/6} = \frac{1/12}{1/3} = \frac{1}{4} \]

# P(Y\leq2 \cap X =2) = b
b <- xy_df %>%
  filter(Y<=0 & X==2) 

prob_b <- sum(b$Probability)

# P(X=2) =b2

b2 <- xy_df %>%
  filter(X==2)

prob_b2 <- sum(b2$Probability)

#solution
prob_b/prob_b2
## [1] 0.25

c) Are X and Y independent?

In order to show that X and Y are independent, we need to prove that for each X and Y, \(P(X=x \cap Y=y) = P(X=x) \cdot P(Y=y)\).

First we will look at \(P(X=-1 \cap Y=-1)\):

\[ (X=-1 \cap Y=-1) = (1/36 + 1/6 + 1/12) \cdot (1/18 + 1/12) = 5/18 \cdot 1/216 \neq 0 \]

c_x <- xy_df %>%
  filter(X==-1)

prob_c_x <- sum(c_x$Probability)
print(prob_c_x)
## [1] 0.1388889
c_y <- xy_df %>%
  filter(Y==-1)

prob_c_y <- sum(c_y$Probability)
print(prob_c_y)
## [1] 0.2777778
# test to see if equal
prob_c_y == prob_c_x
## [1] FALSE

We can already confirm that X and Y are not independent because \(P(X=-1 \cap Y=-1)\) is not equal to 0.

d) What is the distribution of Z = XY ?

# Create a dataframe with the given values
xy_df_z <- xy_df %>%
  mutate(
    Probability = as.numeric(c(0, 1/18, 0, 1/12, 1/36, 0, 1/36, 0, 1/6, 1/18, 1/6, 1/12, 1/12, 0, 1/12, 1/6)),
    Z = X * Y)

# Print the dataframe
print(xy_df_z)
##     X  Y Probability  Z
## 1  -1 -1  0.00000000  1
## 2  -1  0  0.05555556  0
## 3  -1  1  0.00000000 -1
## 4  -1  2  0.08333333 -2
## 5   0 -1  0.02777778  0
## 6   0  0  0.00000000  0
## 7   0  1  0.02777778  0
## 8   0  2  0.00000000  0
## 9   1 -1  0.16666667 -1
## 10  1  0  0.05555556  0
## 11  1  1  0.16666667  1
## 12  1  2  0.08333333  2
## 13  2 -1  0.08333333 -2
## 14  2  0  0.00000000  0
## 15  2  1  0.08333333  2
## 16  2  2  0.16666667  4
# find the Z=XY distribution;
Z_df <- xy_df_z %>%
  select(Z, Probability) %>%
  group_by(Z) %>%
  summarise(Total_Probability = sum(as.numeric(Probability))) %>%
  as.data.frame()

# Z=XY distribution
print(Z_df)
##    Z Total_Probability
## 1 -2         0.1666667
## 2 -1         0.1666667
## 3  0         0.1666667
## 4  1         0.1666667
## 5  2         0.1666667
## 6  4         0.1666667