Session 3: Probability and Sampling
A random process is a situation in which we know what outcomes could happen, but we don’t know which particular outcome will happen.
Examples: coin tosses, die rolls, iTunes shuffle, whether the stock market goes up or down tomorrow, etc.
It can be helpful to model a process as random even if it is not truly random.
An experiment is any process that generates well-defined outcomes.
The sample space for an experiment is the set of all experimental outcomes.
An experimental outcome is called a sample point.

Boring has invested in two stocks, Marrley Oil and Clean Energy. Boring has determined that the possible outcomes of these investments three months from now are as follows:
image
Boring Investments can be viewed as a two-step experiment. It involves two stocks, each with a set of experimental outcomes:
Marrley Oil: \(n_1 = 4\)
Clean Energy: \(n_2 = 2\)
Total Number of Experimental Outcomes: \(n_1 \times n_2 = 8\)

A tree diagram can represent the sample space for a multiple-step experiment:
image
A second useful counting rule enables us to count the number of experimental outcomes when \(n\) objects are to be selected from a set of \(N\) objects.
Number of Combinations of \(N\) Objects Taken \(n\) at a Time: \[\mathrm{C}(N,n) = \mathrm{C}_n^{N} = {}^{N}\mathrm{C}_n = {}_{N}\mathrm{C}_n = {N \choose n} =\frac{N!}{n!(N-n)!}\]
where: \[\begin{aligned} N! &= N \times (N-1) \times (N-2) \cdots \times 2 \times 1 \\ n! &= n \times (n-1) \times (n-2) \cdots \times 2 \times 1 \\ 0! &= 1 \end{aligned}\]
A third useful counting rule enables us to count the number of experimental outcomes when \(n\) objects are to be selected from a set of \(N\) objects, where the order of selection is important.
Number of Permutation of \(N\) Objects Taken \(n\) at a Time: \[\mathrm{A}(N,n) = \mathrm{P}(N,n) = \mathrm{A}_n^{N} = {}^{N}\mathrm{A}_n = {}_{N}\mathrm{A}_n = n!{N \choose n} =\frac{N!}{(N-n)!}\]
where: \[\begin{aligned} N! &= N \times (N-1) \times (N-2) \cdots \times 2 \times 1 \\ n! &= n \times (n-1) \times (n-2) \cdots \times 2 \times 1 \\ 0! &= 1 \end{aligned}\]
Probability is a numerical measure of the likelihood that an event/outcome will occur.
There are several possible interpretations of probability but they (almost) completely agree on the mathematical rules probability must follow.
\(P(A)\) = Probability of event A
\(0 \le P(A) \le 1\)
A probability of near zero indicates an event is unlikely to occur;
A probability near 1 indicates an event is almost certain to occur.
Other probabilities between 0 and 1 represent degrees of likelihood that an event will occur.

The sum of probabilities of all possible outcomes is 1
The following arguments are TRUE or FALSE
If an event with probability 1, it will definitely happen.
If an event with probability 0, it will definitely not happen.
If an event will definitely happen, its probability is 1
If an event will definitely not happen, its probability is 0
image
Frequentist interpretation:
Bayesian interpretation:
A Bayesian interprets probability as a subjective degree of belief: For the same event, two different individuals could have different viewpoints and so assign different probabilities.
Largely popularised by revolutionary advances in computational technology and methods during the last twenty years.
Law of large numbers (LLN) states that as more observations are collected, the proportion of occurrences with a particular outcome, \(\hat{p}_n\), converges to the probability of that outcome, \(p\).
When tossing a fair coin, if heads comes up on each of the first 10 tosses, what do you think the chance is that another head will come up on the next toss? 0.5, less than 0.5, or more than 0.5?
\[\underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{H} \hspace{1mm} \underline{?}\]
The probability is still 0.5, or there is still a 50% chance that another head will come up on the next toss. \[P(H \text{ on 11}^{th} \text{ toss}) = P(T \text{ on 11}^{th} \text{ toss}) = 0.5\]
The coin is not “due" for a tail.
The common misunderstanding of the LLN is that random processes are supposed to compensate for whatever happened in the past; this is just not true and is also called gambler’s fallacy (or law of averages).
There are three methods for assigning probabilities:
Classical Method: Based on assumption of equally likely outcomes
Relative Frequency Method: Based on experimentation or historical data
Subjective Method: Based on judgement
Applying the subjective method, an analyst made the following probability assignments.
image
An event is a collection of sample points.
The probability of any event is equal to the sum of the probabilities of the sample points in the event.
If we can identify all the sample points of an experiment and assign a probability to each, we can compute the probability of an event.

For example, let event M = Marrley Oil Profitable. Then: \[M = \{(10, 8), (10, -2), (5, 8), (5, -2)\}\]
\[\begin{aligned} \mathbb{P}(M) & = \mathbb{P}(10, 8) + \mathbb{P}(10, -2) + \mathbb{P}(5, 8) + \mathbb{P}(5, -2) \\ & = 0.20 + 0.08 + 0.16 + 0.26 \\ & = 0.70 \end{aligned}\]
The complement of event A is defined to be the event consisting of all sample points that are not in A.
The complement of \(A\) is denoted by \(A^{\complement}\)

The union of events A and B is the event containing all sample points that are in A or B or both.
The union of events A and B is denoted by \(A \cup B\).

Event M = Marrley Oil Profitable
Event C = Clean Energy Profitable
\(M \cup C\) = Marrley Oil Profitable or Clean Energy Profitable

In mathematics: \[M \cup C = \{(10, 8), (10, -2), (5, 8), (5, -2), (0, 8), (-20, 8) \}\]
\[\begin{aligned} \mathbb{P}(M \cup C) & = \mathbb{P}(10, 8) + \mathbb{P}(10, -2) + \mathbb{P}(5, 8) + \mathbb{P}(5, -2) + \mathbb{P}(0, 8) + \mathbb{P}(-20, 8) \\ & = 0.20 + 0.08 + 0.16 + 0.26 + 0.10 + 0.02 \\ & = 0.82 \end{aligned}\]
The intersection of events A and B is the set of all sample points that are in both A and B.
The intersection of events A and B is denoted by \(A \cap B\).

Event M = Marrley Oil Profitable
Event C = Clean Energy Profitable
\(M \cap C\) = Marrley Oil Profitable and Clean Energy Profitable

In mathematics: \[M \cap C = \{(10, 8), (5, 8) \}\]
\[\begin{aligned} \mathbb{P}(M \cap C) & = \mathbb{P}(10, 8) + \mathbb{P}(5, 8) \\ & = 0.20 + 0.16 \\ & = 0.36 \end{aligned}\]
The addition law provides a way to compute the probability of event A, or B, or both A and B occurring.
The law is written as: \[P(A \cup B) = P(A) + P(B) - P(A \cap B)\]
Event M = Marrley Oil Profitable
Event C = Clean Energy Profitable
\(M \cup C\) = Marrley Oil Profitable or Clean Energy Profitable

As we know, \[\mathbb{P}(M) =0.70, \mathbb{P}(C) = 0.48, \mathbb{P}(M \cap C) = 0.36\]
Thus \[\begin{aligned} \mathbb{P}(M \cup C) & =\mathbb{P}(M) + \mathbb{P}(C) - \mathbb{P}(M \cap C) \\ & = 0.70 + 0.48 - 0.36 \\ & = 0.82 \end{aligned}\]
This result is the same as that obtained earlier using the definition of the probability of an event.
Two events are said to be mutually exclusive if the events have no sample points in common.
Two events are mutually exclusive if, when one event occurs, the other cannot occur.

If events A and B are mutually exclusive, \[P(A \cap B) = 0\]
The addition law for mutually exclusive events is \[P(A \cup B) = P(A) + P(B)\]
The probability of an event given that another event has occurred is called a conditional probability.
The conditional probability of A given B is denoted by \(P(A|B)\).
A conditional probability is computed as follows: \[P(A|B) = \frac{P(A \cap B)}{P(B)}\]
Event M = Marrley Oil Profitable
Event C = Clean Energy Profitable
\(\mathbb{P}(C|M)\) = Clean Energy Profitable given Marrley Oil Profitable

As we know, \[\mathbb{P}(M) =0.70, \mathbb{P}(M \cap C) = 0.36\]
Thus \[\mathbb{P}(C | M) = \frac{\mathbb{P}(M \cap C) }{ \mathbb{P}(M)} = \frac{0.36}{0.70} = 0.5143\]
The multiplication law provides a way to compute the probability of the intersection of two events.
The law is written as: \[P(A \cap B) = P(B)P(A|B)\]
Event M = Marrley Oil Profitable
Event C = Clean Energy Profitable
\(M \cap C\) = Clean Energy Profitable and Marrley Oil Profitable

As we know, \[\mathbb{P}(M) =0.70, \mathbb{P}(C \cap M) = 0.5143\]
Thus \[\mathbb{P}(M \cap C) = \mathbb{P}(M) \mathbb{P}(M|C) = 0.70 \times 0.5143 = 0.36\]
This result is the same as that obtained earlier using the definition of the probability of an event.
If the probability of event A is not changed by the existence of event B, we would say that events A and B are independent.
Knowing that the coin landed on a head on the first toss does not provide any useful information for determining what the coin will land on in the second toss. \(\rightarrow\) Outcomes of two tosses of a coin are independent.
Knowing that the first card drawn from a deck is an ace does provide useful information for determining the probability of drawing an ace in the second draw. \(\rightarrow\) Outcomes of two draws from a deck of cards (without replacement) are dependent.
Two events A and B are independent if: $$
\[\begin{aligned} P(A|B) & = P(A) \\ & \text{ or } \\ P(B|A) &= P(B) \end{aligned}\]$$
The multiplication law also can be used as a test to seeif two events are independent.
The law is written as: \[\mathbb{P}(A \cap B) = \mathbb{P}(A) \mathbb{P}(B)\]
Event M = Marrley Oil Profitable
Event C = Clean Energy Profitable

Are events M and C independent?
Does \(\mathbb{P}(M \cap C) = \mathbb{P}(M) \mathbb{P}(C)\) ?
As we know, \[\mathbb{P}(M \cap C) = 0.36, \mathbb{P}(M) =0.70, \mathbb{P}(C) =0.48\]
But \[\mathbb{P}(M) \times \mathbb{P}(C) = 0.70 \times 0.48 = 0.34 \neq 0.36 = \mathbb{P}(M \cap C)\]
Hence, M and C are not independent.
If we were to randomly select 5 persons in Edinburgh, what is the probability that at least one is insured? Assuming we know the probability of being insured in Edinburgh is 25.5% .
The sample space for the number of persons in Edinburgh who are insured would be: \[S = \{0, 1, 2, 3, 4, 5\}\]
We are interested in instances where at least one person is insured: \[S = \{0, 1, 2, 3, 4, 5 \}\]
So we can divide up the sample space into two categories: \[S = \{0, at~least~one \}\]
Since the probability of the sample space must add up to 1: \[\begin{aligned} \mathbb{P}(at~least~1~insured) &=& 1 - \mathbb{P}(none~insured) \\ &=& 1 - [(1-0.255)^5] \\ &=& 0.77 \end{aligned}\]
In probability theory, the law (or formula) of total probability is a fundamental rule relating marginal probabilities to conditional probabilities. \[\mathbb{P}(A) = \mathbb{P}(A \cap B) + \mathbb{P}(A \cap B^{\complement})\]
It expresses the total probability of an outcome which can be realised via several distinct events, hence the name.
Multiple distinct events (\(B_n\) are Mutually exclusive events, and \(B = \cup B_n\)) \[\mathbb{P}(A) = \sum_n \mathbb{P}(A \cap B_n)\]
Apply conditional probability, then we can have \[\mathbb{P}(A) = \sum_n \mathbb{P}(A | B_n) \mathbb{P}(B_n)\]
Let’s look at a question:
The students who complete all assignments can probably pass the exam (probability is 0.95).
But if the students didn’t complete all assignments, they have less chance to pass the exam (probability is 0.3).
Now, in our class, 90% students have completed all assignments at the end of the term.
Question: what is the probability that a student passes the exam?
Diagram
Solution: Let \(B\) denote student passes exam, let \(A\) denote student completed all assignments
\[\begin{aligned} \mathbb{P}(B) & = \mathbb{P}(BA \cup BA^{\complement}) =\mathbb{P}(BA) + \mathbb{P}(BA^\complement) \\ & = \mathbb{P}(B|A)\mathbb{P}(A) + \mathbb{P}(B|A^{\complement})\mathbb{P}(A^{\complement}) \\ & = 0.95 \times 0.9 + 0.3 \times 0.1 \\ & = 0. 885 \end{aligned}\]
Diagram
Solution: Let \(B\) denote student passes exam, let \(A_k\) denote that the student completed \(k\) assignments, \[\begin{aligned} \mathbb{P}(B) & = \mathbb{P}(B|A_0)\mathbb{P}(A_0) + \cdots \\ & \quad + \mathbb{P}(B|A_k)\mathbb{P}(A_k) + \cdots \\ & \quad + \mathbb{P}(B|A_N)\mathbb{P}(A_N) \end{aligned}\]
Conditional Probability / Bayes’ Theorem: \[\mathbb{P}(A|B) = \frac{\mathbb{P}(B|A) \mathbb{P}(A)}{\mathbb{P}(B)}\]
The conditional probability formula is a special case of the Bayes’ Theorem, which is applicable even when events have more than just two outcomes.
Bayes’ Theorem:
\[\mathbb{P}(outcome~A_1~of~variable~1~|~outcome~B~of~variable~2)\] \[= \frac{\mathbb{P}(B|A_1)\mathbb{P}(A_1)}{\mathbb{P}(B|A_1)\mathbb{P}(A_1) + \mathbb{P}(B|A_2)\mathbb{P}(A_2) + \cdots + \mathbb{P}(B|A_k)\mathbb{P}(A_k)}\]
where \(A_2\), \(\cdots\), \(A_k\) represent all other possible outcomes of variable 1.
Let’s look at a question:
The students who complete all assignments can probably pass the exam (probability is 0.95).
But if the students didn’t complete all assignments, they have less chance to pass the exam (probability is 0.3).
Now, in our class, 90% students have completed all assignments at the end of the term.
Question: suppose that Peter has passed the exam, what is the probability that Peter completed all assignments?
Diagram
Solution: \[\begin{aligned} \mathbb{P}(A | B) & = \frac{\mathbb{P}(AB)}{\mathbb{P}(B)} \\ & = \frac{\mathbb{P}(B|A) P(A)}{\mathbb{P}(B)} \\ & = \frac{0.95 \times 0.9}{0.885} \\ & \approx 0.97 \end{aligned}\]
Diagram
Solution: \[\begin{aligned} \mathbb{P}(A_k | B) & = \frac{\mathbb{P}(A_k B)}{\mathbb{P}(B)} \\ & = \frac{\mathbb{P}(B|A_k) P(A_k)}{\mathbb{P}(B)} \\ & = \frac{\mathbb{P}(B|A_k) P(A_k)}{\sum_{i=0}^N \mathbb{P}(B|A_i)\mathbb{P}(A_i)} \end{aligned}\]
Total Probability Formula \[\mathbb{P}(\text{Effect}) = \sum_{i=0}^n \mathbb{P}(\text{Effect}|C_i)\mathbb{P}(C_i)\]
Bayes’ Formula \[\mathbb{P}(C_j |\text{Effect}) = \frac{\mathbb{P}(\text{Effect}|C_j) \mathbb{P}(C_j)}{ \sum_{i=0}^n \mathbb{P}(\text{Effect}|C_i)\mathbb{P}(C_i)}\]
image
A random variable is a numeric quantity whose value depends on the outcome of a random event
We use a capital letter, like \(X\), to denote a random variable
The values of a random variable are denoted with a lowercase letter, in this case \(x\)
For example, \(\mathbb{P}(X = x)\)
There are two types of random variables:
Discrete random variables often take only integer values, e.g., Number of credit hours, Difference in number of credit hours this term vs last
Continuous random variables take real (decimal) values, e.g., Cost of books this term, Difference in cost of books this term vs last
| Question | Random Variable \(X\) | Type |
|---|---|---|
| Family size | \(X =\) Number of dependents reported on tax return | Discrete |
| Distance from home to store | \(X =\) Distance in miles from home to the store site | Continuous |
| Own dog or cat | \(X = 1\) if own no pet; \(= 2\) if own dog(s) only; \(= 3\) if own cat(s) only; \(= 4\) if own dog(s) and cat(s) | Discrete |
We are often interested in the average outcome of a random variable.
We call this the expected value (mean), and it is a weighted average of the possible outcomes \[\mu = \mathbb{E}(X) = \sum_{i = 1}^k x_i ~ \mathbb{P}(X = x_i)\]
In a game of cards you win
$1 if you draw a heart,
$5 if you draw an ace (A, including the ace of hearts),
$10 if you draw the king of spades (K\(\heartsuit\)) and nothing for any other card you draw.
Write the probability model for your winnings, and calculate your expected winning.
| Event | \(X\) | \(\mathbb{P}(X)\) | \(X ~ \mathbb{P}(X)\) |
|---|---|---|---|
| Heart (not ace) | \(1\) | \(\frac{12}{52}\) | \(\frac{12}{52}\) |
| Ace | \(5\) | \(\frac{4}{52}\) | \(\frac{20}{52}\) |
| King of spades | \(10\) | \(\frac{1}{52}\) | \(\frac{10}{52}\) |
| All else | \(0\) | \(\frac{35}{52}\) | \(0\) |
| Total | \(\mathbb{E}(X) = \frac{42}{52} \approx 0.81\) |
Below is a visual representation of the probability distribution of winnings from this game:
We are also often interested in the variability in the values of a random variable.
\[\sigma^2 = Var(X) = \sum_{i = 1}^k (x_i - \mathbb{E}(X))^2 \mathbb{P}(X = x_i)\] \[\sigma = SD(X) = \sqrt{Var(X)}\]
For the previous card game example, how much would you expect the winnings to vary from game to game?
| \(X\) | \(\mathbb{P}(X)\) | \(X ~ \mathbb{P}(X)\) | \((X - \mathbb{E}(X))^2\) | \(\mathbb{P}(X) ~ (X - \mathbb{E}(X))^2\) |
|---|---|---|---|---|
| 1 | \(\frac{12}{52}\) | \(1 \times \frac{12}{52} = \frac{12}{52}\) | \((1 - 0.81)^2 = 0.0361\) | \(\frac{12}{52} \times 0.0361 = 0.0083\) |
| 5 | \(\frac{4}{52}\) | \(5 \times \frac{4}{52} = \frac{20}{52}\) | \((5 - 0.81)^2 = 17.5561\) | \(\frac{4}{52} \times 17.5561 = 1.3505\) |
| 10 | \(\frac{1}{52}\) | \(10 \times \frac{1}{52} = \frac{10}{52}\) | \((10 - 0.81)^2 = 84.4561\) | \(\frac{1}{52} \times 84.0889 = 1.6242\) |
| 0 | \(\frac{35}{52}\) | \(0 \times \frac{35}{52} = 0\) | \((0 - 0.81)^2 = 0.6561\) | \(\frac{35}{52} \times 0.6561 = 0.4416\) |
| \(\mathbb{E}(X) = 0.81\) | 3.4246 | |||
| \(SD(X) = \sqrt{3.4246} = 1.85\) |
A linear combination of random variables \(X\) and \(Y\) is given by
\[aX + bY\]
where \(a\) and \(b\) are some fixed numbers.
The average value of a linear combination of random variables is given by \[E(aX + bY) = a \times \mathbb{E}(X) + b \times \mathbb{E}(Y)\]
The variability of a linear combination of two independent random variables is calculated as \[V(aX + bY) = a^2 \times V(X) + b^2 \times V(Y)\]
The standard deviation of the linear combination is the square root of the variance.
Notes: If the random variables are not independent, the variance calculation gets a little more complicated and is beyond the scope of this course.
Random variables do not work like normal algebraic variables: \[X + X \ne 2X\]
\[\begin{aligned} E(X + X) &= \mathbb{E}(X) + \mathbb{E}(X) \\ &= 2 \mathbb{E}(X) \\ &~ \\ E(2X) &= 2 \mathbb{E}(X) \\ &~ \end{aligned}\]
\[\begin{aligned} Var(X + X) &= Var(X) + Var(X)~{\scriptsize \text{(assuming independence)}} \\ &= 2~Var(X) \\ &~ \\ Var(2X) &= 2^2~Var(X) \\ &= 4~Var(X) \end{aligned}\]
\(E(X + X) = E(2X)\), but \(Var(X + X) \ne Var(2X)\).
The probability distribution for a random variable describes how probabilities are distributed over the values of the random variable.
We can describe a discrete probability distribution with a table, graph, or equation.
The probability distribution is defined by a probability function, denoted by \(\mathbb{P}(x)\), which provides the probability for each value of the random variable.
The required conditions for a discrete probability function are: $$
\[\begin{aligned} & 0 \leq \mathbb{P}(x) \leq 1, \text{ for all } x \\ & \sum \mathbb{P}(x) = 1 \end{aligned}\]$$
A continuous random variable X can assume any value \(x\) in an interval on the real line or in a collection of intervals.
It is not possible to talk about the probability of the random variable assuming a particular value \(x\). Instead, we talk about the probability of the random variable assuming a value within a given interval.
The probability is defined by the area under the probability density function \(f(x)\).
Below is a histogram of the distribution of heights of US adults.
The proportion of data that falls in the shaded bins gives the probability that a randomly sampled US adult is between 180 cm and 185 cm.

Since height is a continuous numerical variable, its probability density function is a smooth curve.

Therefore, the probability that a randomly sampled US adult is between 180 cm and 185 cm can also be estimated as the shaded area under the curve.

Since continuous probabilities are estimated as “the area under the curve", the probability of a person being exactly 180 cm (or any exact value) is defined as 0.

