Joint probability and conditional probability are closely intertwined, however elusive for beginners, sometimes even experienced data scientists are hard to tell the subtlety.
We will tackle the joint probability first.
The joint probability is defined as
$$ P(A\cap B) = P(A)P(B) $$when we talking about joint probability, we implicitly assume that
For instance, I throw a dice (event A) and you also throw a dice (event B) in the mean time. The joint probability of obtaining two $1$'s is $\frac{1}{6}\times\frac{1}{6}$.
If $A$ and $B$ are not independent, then it is pointless to talk about joint probability, because they are affection each other's results. In other words, if $A$ and $B$ are dependent, when $A$ happens, the probability of $B$ happening is no longer $P(B)$ anymore, hence $P(AB) = P(A)P(B)$ won't hold in this case.
What is the joint probability of rolling the number $6$ twice in a fair six-sided dice?
$\text{Event A}$ = $\text{Obtaining number 6}$
$$ P(A\cap A)=\frac{1}{6}\frac{1}{6}= \frac{1}{36} $$What is the joint probability of obtaining 3 times head followed by 3 times tail in a sequence of coin tosses?
.5**6
0.015625
What is the joint probability that you pick a card which is larger than 4 and less than $10$ and in the meanwhile a $diamond$?
There are five cards in range $(4, 10)$, probability is $\frac{5}{52}$, considering four suits $\frac{5\times 4}{52}$, and thirteen cards for each suit.
$P(A\cap B) = P(A)P(B) = \frac{5\times 4}{52}\frac{13}{52}$
(5*4/52)*(13/52)
0.09615384615384616
Conditional probability is more complicated, denoted as
$$ P(B|A)= \frac{P(A\cap B)}{P(A)}=\frac{P(A\cap B)}{P(A\cap B)+P(A\cap B^C)} $$which reads, the probability of $B$ given $A$. Here we treat $A$ as a fact, it either happens or assumed to happen. $B^C$ is the complement event of $A$, such that $P(B^C)+P(B) =1 $
What is the probability of drawing a card, given which is a $\text{diamond}$, that is also larger than 4 and less than $10$?
Note how we rephrase the question than Example 3 in last section. When we are talking about conditional probability, the sample space is usually different from joint probability, here the sample space changes from all deck to $\text{diamonds}$.
There are $13$ cards of diamonds, this is the new sample space. And in this new sample space, we count how many numbers there are in $(4,\ 10)$. There are 5 numbers. Thus
$P(A|B) = \frac{5}{13}$
5/13
0.38461538461538464
Then what is the joint probability of $P(A\cap B)$? Using multiplication rule $P(A\cap B) = P(A|B)P(B)$.
5/13*1/4
0.09615384615384616
The joint probability only makes sense is because drawing a $\text{diamond}$ and in $(4 <x< 10)$ are independent events.
Note that we have reproduced the same result of the joint probability in Example 3 of last section. Note that, this is also a common way of calculating joint probability
We roll a fair die twice and obtain two numbers $X_1= a$ and $X_2= b$. Given $a+b=7$, what is the probability that $a=4$ or $b=4$?
$\text{Event A}$ : $a = 4$ or $b = 4$
$\text{Event B}$ : $a+b = 7$
There are only two possibilities of obtaining a $7$ if either $a$ or $b$ equals $4$, that are $(3, 4)$ and $(4, 3)$. And two dice have $6^2 = 36$ combinations, thus $P(A\cap B) = \frac{2}{36}$.
To obtain $7$ there are $6$ combination: $(1, 6), (2, 5), (3,4), (4,3), (5,2),(6, 1)$, this is actually the sample space, so we get
$$\frac{P(A\cap B)}{P(B)}= \frac{2}{36}\Big/\frac{6}{36}=\frac{1}{3}$$Consider a family that has two children. We are interested in the children's genders. The sample space of gender is $S=\{(G,G),(G,B),(B,G),(B,B)\}$. Also assume that all four possible outcomes are equally likely.
The first question's sample space is $\{(G,G),(G,B)\}$, the answer is $1/2$.
The second question's sample space is $\{(G,G),(G,B),(B,G)\}$, the answer is $1/3$.
Let me define two events:
$\text{Event A}$: $\text{Obtaining head when tossing a coin}$
$\text{Event B}$: $\text{Raining today}$
What is $P(A|B)$? Unless you believe weather will affect your winning odds of gambling, the sober answer is that it doesn't have a conditional probability.
That's exactly why we mentioned in the beginning that joint probability only makes sense in the context of probabilistic independence.
Independence and disjoint are entirely disparate concepts. Disjoint events mean if $A$ happens, then $B$ certainly can't happen, which exactly assures they are dependent.
Formally, consider two events $A$ and $B$, with $P(A) \neq 0$ and $P(B) \neq 0$.
We can show that if $A$ and $B$ are disjoint, we have
$$ P(A \cap B)=\varnothing \neq P(A) P(B) $$Thus, $A$ and $B$ are not independent.
If $B_{1}, B_{2}, B_{3}, \cdots B_k$ are partitions of the sample space $S$, then for any event $A$ we have
$$ P(A)=\sum_{i=1}^k P\left(A \cap B_{i}\right)=\sum_{i=1}^k P\left(A | B_{i}\right) P\left(B_{i}\right) $$This is called law of total probability.
A person has undertaken a mining job. The probabilities of completion of job on time with and without rain are $0.42$ and $0.90$ respectively. If the probability that it will rain is $0.45$, then determine the probability that the mining job will be completed on time.
Total probability to some extent means that you have to consider all scenarios, in this case raining $R$ and not raining $R^C$.
$\text{Event C}$ : $\text{complete the job on time}$ $$p(C) = p(C|R)p(R) + p(C|R^c)p(R^c) = .42\times .45 + .9\times .55$$
P_C = .42*.45+.9*.55
print('The probability of completing mining job on time is %.3f%%.'%(P_C*100))
The probability of completing mining job on time is 68.400%.
We draw two cards from a well-shuffled deck without replacement. Find the probability of getting a queen in the second draw. So we calculate probabilities of two scenarios (first card queen and first card not queen) then sum up.
$\text{Event Q2}$ : $\text{Drawing a queen in the second card}$
$$ P(Q2) = P(Q2|Q1)P(Q1) + P(Q2|Q1^c)P(Q1^c) = \frac{3}{51}\frac{4}{52}+\frac{4}{51}\frac{48}{52} $$PQ2 = 3/51*4/52+4/51*48/52
print('The probability of drawing a queen in the second card is %.3f%%.'%(PQ2*100))
The probability of drawing a queen in the second card is 7.692%.
In a certain county
When those voters were asked opinions on increasing military spending
What is the probability that a randomly selected voter in this county opposes increasing military spending?
Three scenarios to be taken into consideration, being a Republican, a Democrat or an Independent.
PA = .4*.6+.65*.3+.55*.1
print('The probability that a randomly selected voter in this county opposes increased military spending is %.3f%%.'%(PA*100))
The probability that a randomly selected voter in this county opposes increased military spending is 49.000%.