Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Sets, Outcomes, Experiments, Probability and other perfect things

Probability Lingo

We define a set as a collection of items, sometimes called elements. A set is typically given a capital letter (for example AA) and the elements are included inside curly braces.

Here, we define three sets:

A={a,b,c}C={1,1,3.14}Z={orange,1,puppy dog}\begin{align} A = \{a,b,c\}\\ C = \{-1,1,3.14\}\\ Z = \{\text{orange}, 1, \text{puppy dog}\} \end{align}

The elements inside a set are unordered and do not necessarily need to be numbers. A set can contain any object.
The set AA could have been defined as {a,b,c}\{a,b,c\} or {c,b,a}\{c,b,a\}.
We use the symbol \in to express that an element “is a member of” a set.
For example, aAa \in A can be read “the element aa is a member of the set AA” or “the element aa is in the set AA.”
We can also communicate when an element is not a member of a set with the symbol \notin.
For example, cCc \notin C is read “the element cc is not a member of (not in) the set CC.”

Generating sets:
We can define a set by enclosing in brackets each individual element. S={a,b,c,10}S = \{a,b,c,10\}.
However, some sets may be easier to build with properties.
A property is a function from elements to either true or false.
For example, we could define the property:

P(x)=1 when x is even and 0 when x is odd.\begin{align} P(x) = 1 \text{ when } x \text{ is even and } 0 \text{ when } x \text{ is odd}. \end{align}

To build a set that contains elements with a specific property, we write:

S={xP(x)}orS={xx is an even integer}.\begin{align} S = \{x \mid P(x)\} \quad \text{or} \quad S = \{x \mid x \text{ is an even integer}\}. \end{align}

This is read “the elements xx such that xx is an even integer.”
The vertical bar replaces the words “such that.”

Two sets are equal if they contain the same elements.
In other words, if for an element xx, xAx \in A implies that xBx \in B and if for an element yy, yBy \in B implies that yAy \in A, then the set AA and set BB are equal.
If a set AA and set BB are equal, we write A=BA = B.
If two sets do not contain the same elements, then they are unequal and we write ABA \neq B.

Let’s look at an example:

A={a,b,c}B={b,a,c}C={b,c}\begin{align} A = \{a,b,c\}\\ B = \{b,a,c\}\\ C = \{b,c\} \end{align}

Above, A=BA = B but ACA \neq C and BCB \neq C.

A set AA is a subset of a second set BB if all of the elements in AA are also elements in BB.
We can say that AA is a subset of BB if every element in AA implies that element is in BB, or xAx \in A implies xBx \in B.
We write ABA \subset B to denote that AA is a subset of BB.
To denote that a set AA is not a subset of BB, we write A⊄BA \not\subset B.
In the example above, the set CC is a subset of AA (CA)(C \subset A), but AA is not a subset of CC (A⊄C)(A \not\subset C).

We can build new sets by operating on two or more existing sets.

Set intersection takes as input two or more sets, AA and BB, and returns a set that contains all the elements that are in both AA and BB.
We use the symbol “cap” to denote set intersection: ABA \cap B and often say “A intersect B.”

For the above sets AA and CC, their intersection is:

AC={c,b}\begin{align} A \cap C = \{c,b\} \end{align}

because the element cc belongs to both set AA and set CC and because the element bb belongs to AA and CC.

We can intersect more than two sets.

Let A={a,b,10,12}A = \{a,b,10,12\}, Z={b,10,1}Z = \{b,10,-1\}, U={a,b,c,d,10}U = \{a,b,c,d,10\}.
Then:

AZ={b,10}\begin{align} A \cap Z = \{b,10\} \end{align}

and

AZU={b,10}.\begin{align} A \cap Z \cap U = \{b,10\}. \end{align}

If AA is a subset of BB (AB)(A \subset B), then the only elements both sets have in common are those in AA.
The intersection of AA and BB is then:

If AB then AB=A.\begin{align} \text{If } A \subset B \text{ then } A \cap B = A. \end{align}

Set union takes as input two or more sets and outputs a set that contains all the elements that belong to the first set or the second set or the third set, and so on.
We use the “cup” symbol to denote set union.

As an example, consider the sets AA, ZZ, and UU to be the same as above.
Then AA union ZZ is:

AZ={a,b,10,12,1}\begin{align} A \cup Z = \{a,b,10,12,-1\} \end{align}

This is because each of the above elements belongs to at least one of the sets AA and ZZ.

As another example:

AZU={a,b,c,10,12,1}\begin{align} A \cup Z \cup U = \{a,b,c,10,12,-1\} \end{align}

Intersection and union are the most common set operations.

Before we define the set operation complement, we need to discuss two special sets.

The universal set is the set of all elements.
We denote the universal set with a G\mathcal{G}.
The set which contains no elements is called the empty set, and we denote the empty set as \emptyset.

If a set AA and set BB have no elements in common, then AB=A \cap B = \emptyset.
We often say that the sets AA and BB are disjoint.

For example:

A={1,3,5}Q={2,4,6}AQ=\begin{align} A = \{1,3,5\}\\ Q = \{2,4,6\}\\ A \cap Q = \emptyset \end{align}

Because the intersection between AA and QQ is empty, these sets are disjoint.

Now for our final set operation — complement.
The set complement takes as input a single set, AA, and outputs a set with elements that are members of G\mathcal{G} but are not members of AA.
We denote set complement in one of two ways: AcA^{c} or AA'.


Set operations example

Let’s look at an example of how these sets and set operations work.
Define the universal set, G\mathcal{G}, to be the set of all positive integers (i.e., 1,2,3,4,1,2,3,4,\ldots).
Let’s define the sets:

A1={1},A2={1,2},A3={1,2,3},,An={1,2,3,4,,n}A_{1} = \{1\}, A_{2} = \{1,2\}, A_{3} = \{1,2,3\}, \ldots, A_{n} = \{1,2,3,4,\ldots,n\}.

A1A2={1}A1A5={1}A3A8={3}\begin{align} A_{1} \cap A_{2} = \{1\}\\ A_{1} \cap A_{5} = \{1\}\\ A_{3} \cap A_{8} = \{3\} \end{align}

Note that A3A8A_{3} \cap A_{8} is not the value 3, but the set {3}\{3\}.

The examples above suggest a pattern for any set AiA_{i} and AjA_{j} where iji \leq j:

AiAj={i}.\begin{align} A_{i} \cap A_{j} = \{i\}. \end{align}

Lets look at set union in this example

A1A2={1,2}A1A5={1,2,3,4,5}A3A8={1,2,3,4,5,6,7,8}\begin{align} \begin{aligned} A_{1} \cup A_{2} &= \{ 1,2 \}\\ A_{1} \cup A_{5} &= \{ 1,2,3,4,5 \}\\ A_{3} \cup A_{8} &= \{ 1,2,3,4,5,6,7,8 \}\\ \end{aligned} \end{align}

and we see the following pattern for iji \leq j

AiAj={1,2,3,4,j}=Aj\begin{align} A_{i} \cup A_{j} = \{1,2,3,4\cdots,j \} = A_{j} \end{align}

Because we defined a universal set, we can look at set complement

A1c={2,3,4,5,}A5c={6,7,8,9}A8c={9,10,11,12,}\begin{align} \begin{aligned} A_{1}^{c} &= \{2,3,4,5,\cdots \}\\ A_{5}^{c} &= \{6,7,8,9\cdots \}\\ A_{8}^{c} &= \{9,10,11,12,\cdots \}\\ \end{aligned} \end{align}

Applying set theory to probability

Foundation

The ideas about sets and set operations are the foundations for how we think about probability, about experiments, and hypotheses. We only need to recast the above set ideas to results from an experiment.

We use G\mathcal{G} to define the set of all possible outcomes from an experiment and call this set the sample space. The term “experiment” has a broad meaning. An experiment can mean everything from a randomized controlled trial to an observational study. Here an experiment is the process that generates outcomes.

An outcome is defined as an element of the sample space. An outcome is a single observation from an experiment, and we define an event as a set of outcomes. Most often we use oio_{i} to denote an outcome and EiE_{i} to denote an event.

The probability of an event EE is a mapping from the set EE to a number between, or equal to, the values 0 and 1. We use P(E)P(E) to denote the probability of event EE. We require that the probabilities assigned to individual sets consisting of a single element in EE add up to the probability of EE. Lets suppose there are nn outcomes in the event EE. Then

E={o1,o2,o3,,on}P(E)=P({o1})+P({o2})P({on})\begin{align} \begin{aligned} E &= \{ o_{1}, o_{2}, o_{3}, \cdots, o_{n}\} \\ P(E) &= P(\{o_{1}\}) + P(\{o_{2}\}) \cdots P(\{o_{n}\}) \end{aligned} \end{align}

We further require P(G)=1P(\mathcal{G}) = 1. In other words, the probability that something happens is certain. Note that we do not need to describe how we assign probabilities to events, we only describe what values we expect those numbers to be.

Lets further detail relationships between probabilities of sets that we would expect.

  1. If ABA \subset B then P(A)P(B)P(A) \leq P(B) \label{subsetrule}.

  2. P(AB)P(A)+P(B)P(A \cup B) \leq P(A) + P(B) (why?)

  3. P(AB)=P(A)+P(B)P(AB)P(A \cup B) = P(A) + P(B) - P(A \cap B)

  4. If AA and BB are disjoint then P(AB)=P(A)+P(B)P(A \cup B) = P(A) + P(B)

The following three axioms (knowledge we assume true without proof) are called Kolmogorov’s Axioms.

  1. For any event EE, P(E)0P(E) \geq 0

  2. P(G)=1P(\mathcal{G}) = 1

  3. If E1E_{1} and E2E_{2} are disjoint then P(E1E2)=P(E1)+P(E2)P(E_{1} \cup E_{2}) = P(E_{1}) + P(E_{2})

Example: When we want to compute the probability that an outcome fall in any one of the events, say E1,E2,E3E_{1}, E_{2},E_{3}, knowing that these events have no outcomes in common, that they are disjoint, makes the computation easy. An intuitive way to think about events that are disjoint is if they cannot all occur at the same time. Suppose we wish to study the prevalence of stroke among patients who are older than sixety-five. Strokes can be categorized into transient ischemia attacks (TIA), ischemic stroke (IS), and hemorrhagic stroke (HS). Further lets assume the following probabilities for each event: P({TIA})=0.15P(\{\text{TIA}\}) = 0.15, P({IS})=0.75P(\{\text{IS}\}) = 0.75, P({HS})=0.10P(\{\text{HS}\}) = 0.10, and that these events cannot occur simultaneously. Then the probability of the event E={TIA,HS}E=\{TIA,HS\} can be broken into the union of two disjoint events E={TIA}{HS}E = \{TIA\} \cup \{HS\} and we can use what we know about these disjoint events to compute the probability of EE

P(E)=P({TIA,HS})=P({TIA}{HS})=P({TIA})+P({HS})      disjoint=0.15+0.75=0.90\begin{align} P(E) &= P(\{\text{TIA},\text{HS}\} ) \\ &=P(\{\text{TIA}\} \cup \{\text{HS}\} ) \\ &=P(\{\text{TIA}\}) + P(\{\text{HS}\} ) \;\;\;\text{disjoint} \\ &= 0.15 + 0.75 = 0.90 \end{align}

The principle of equally likely outcomes---one way to assign probabilities

There are many different ways to assign probabilities to events. In this text, we will only consider using the principle of equally likely outcomes to assign probabilities. The principle of equally likely outcomes (PELO) states that the probability we assign to every event which contains a single outcome, Ei={oi}E_{i} = \{o_{i}\}, in a sample space G\mathcal{G} is equal.

We can use this principle to assign probabilities first to every individual outcome and then to arbitrary events. Assume the PELO is true, then

o1,o1,o1,,onGEi={oi}E1E2E3En=G    (why?)P(E1E2En)=P(G)=1P(E1E2En)=P(E1)+P(E2En)    (disjoint)P(E1)+P(E2)+P(En)=1np=1    (p is the constant prob. we are after)p=1/n\begin{align} o_{1},o_{1},o_{1}, \cdots,o_{n} \in \mathcal{G}\\ E_{i} = \{o_{i}\}\\ E_{1} \cup E_{2} \cup E_{3} \cup \cdots \cup E_{n} = \mathcal{G} \;\; \text{(why?)}\\ P(E_{1} \cup E_{2} \cup \cdots \cup E_{n}) = P(\mathcal{G}) = 1 \\ P(E_{1} \cup E_{2} \cup \cdots \cup E_{n}) = P(E_{1}) + P(E_{2} \cup \cdots \cup E_{n}) \;\; (\text{disjoint})\\ P(E_{1}) + P(E_{2}) + \cdots P(E_{n}) = 1\\ n \cdot p = 1 \;\; (p \text{ is the constant prob. we are after})\\ p = 1/n \end{align}

The PELO tells us that the probability of an event with a single outcome is equal to one divided by the total number of outcomes in the sample space. The PELO also tells us that for a sample space with nn elements the probability of an event E={o1,o20,o4}E = \{o_{1},o_{20},o_{4}\} that contains three outcomes is P(E)=320P(E) = \frac{3}{20}.


An example when, and when not, the PELO applies.

PELO only works when we expect each outcome in our sample space to be equally likely.\

Example 1 Suppose our experiment is a coin toss and we will observe whether or not the coin lands heads up (H) or tails up (T). If we assume the coin has not been altered in any way, then PELO applies. Our sample space is G=H,T\mathcal{G} = {H,T}. Because there are two outcomes in our sample space, P({H})=1/2P(\{H\}) = 1/2 and P({T})=1/2P(\{T\}) = 1/2.

Example 2 Suppose for our experiment we observe for one year a single patient who was admitted to the hospital because of an influenza infection and we plan to observe if that patient returns to the hospital because of a second infection. Our sample space contains one outcome RR if the patient is re-admitted to the hospital within one year and a second outcome if they are no re-admitted (NN). Our sample space is G=R,N\mathcal{G} = {R,N}. If we applied the PELO to this problem we would have to assume the probability this patient returns, or does not return, are equal. Intuitively,it feels unreasonable to assume these two events have equal probabilities.

We need an additional way to assign probabilities.


A frequentest approach to assigning probabilities

An empirical approach to assign probabilities to an event AA with sample space G\mathcal{G} is to do the following:

  1. Generate 1,2,3,4,,N1, 2, 3, 4, \cdots, N outcomes from G\mathcal{G}

  2. Define a variable N(A)N(A) and set that variable to zero.

  3. If the 1st outcome is a member of AA than add one N(A)N(A), otherwise move on

  4. If the 2nd outcome is a member of AA than add one to N(A)N(A)\ \vdots

  5. If the Nth outcome is a member of AA than add one to N(A)N(A)

The above algorithm defined a variable N(A)N(A) that counts the number of outcomes that belong to AA out of the NN generated outcomes. We can assign to AA the probability

P(A)=N(A)NP(A) = \frac{N(A)}{N}

that is, the number of times we observed an outcome that belonged to A divided by the number of outcomes we observed.

As an example, suppose we want to understand the probability that patients with non-medically treated type II diabetes transition to needing treatment within one year of their diagnosis. Our outcomes are G\mathcal{G} = {“need treatment” and “no treatment”}. To assign a probability to the event E={need treatment}E = \{\text{need treatment}\} using the frequentest approach we decide to request anonymized patient records from a set of hospitals, asking that each hospital only send those patients who had an original diagnosis of type II diabetes without medication and who have had a physician visit one year more later. After our data request, we received 5,000 patient records and find that 1,585 of these patients were asked to start medication for their type II diabetes within one year. A frequentest approach would assign

P(E)=1585/5000=0.317P(E) = 1\,585/5\,000 = 0.317

and also assign to the event F={no treatment}F=\{\text{no treatment}\}

P(F)=0.683    (why?)P(F) = 0.683 \; \; \text{(why?)}

Conditional probabilities

Assume a sample space G\mathcal{G}. We define the conditional probability of event AA given event BB as

P(AB)=P(AB)P(B)P(A|B) = \frac{P(A \cap B)}{P(B)}

Example: Lets use the definition above to compute the probability of an event AA given G\mathcal{G}, the sample space (remember that the sample space is a set and so technically an event). By the definition of conditional probability

P(AG)=P(AG)P(G)P(A|\mathcal{G}) = \frac{P(A \cap \mathcal{G})}{P(\mathcal{G})}

We know that P(G)=1P(\mathcal{G}) = 1 (Kolmogorov axioms) and so

P(AG)=P(AG)P(G)P(AG)=P(AG)1=P(AG)\begin{align} P(A|\mathcal{G}) &= \frac{P(A \cap \mathcal{G})}{P(\mathcal{G})} \\ P(A|\mathcal{G}) &= \frac{P(A \cap \mathcal{G})}{1}\\ &= P(A \cap \mathcal{G}) \end{align}

The set AA must be a subset of G\mathcal{G} and so

P(AG)=P(AG)=P(A)P(A|\mathcal{G}) = P(A \cap \mathcal{G}) = P(A)

The above example shows that we can think of the event that we condition on as a new sample space. Lets return to our example of vaccination and the incidence of infection.

To compute the probability of infection given a patient was vaccinated we need to compute

P(infvacc)=P(infvacc)P(vacc)P( \text{inf} | \text{vacc} ) = \frac{P(\text{inf} \cap \text{vacc})}{ P(\text{vacc})}

where the event “inf” contains those outcomes in Gexperiment\mathcal{G}_{\text{experiment}} which have “infected” in the fist position of their tuple (infected,)(\text{infected}, \cdot) and the event “vacc” contains those outcomes which have “vaccinated” in the second position of their tuple (,vaccinated)(\cdot, \text{vaccinated} ). Events which hold one or more positions in a tuple constant are often called marginal events and the associated probability is called a marginal probability. Then P(infvacc)P(\text{inf} \cap \text{vacc}) are those outcomes with “infected” in the first position and “vaccinated” in the second position. We have a single outcome where this happens: {(infected, vaccinated)} and this outcome has a probability of P(infvacc)=0.1P(\text{inf} \cap \text{vacc}) = 0.1.

Computing P(vacc)P(\text{vacc}) is only slightly more difficult. We can use what we learned about unions and disjoint events for help.

P(vacc)=P({(infected,vacc),(not infected,vacc)})=P({(infected,vacc)}{(not infected,vacc)})=P({(infected,vacc)})+P({(not infected,vacc)})=0.1+0.4=0.5\begin{align} \begin{aligned} P(\text{vacc}) &= P( \{ (\text{infected},\text{vacc} ), (\text{not infected},\text{vacc} ) \} ) \\ &= P( \{ (\text{infected},\text{vacc} )\} \cup \{(\text{not infected},\text{vacc} ) \} ) \\ &= P( \{ (\text{infected},\text{vacc} )\})+ P(\{(\text{not infected},\text{vacc} ) \} )\\ &= 0.1+0.4 = 0.5 \end{aligned} \end{align}

We arrive at our final result.

P(infvacc)=P(infvacc)P(vacc)=0.10.5=0.2P( \text{inf} | \text{vacc} ) = \frac{P(\text{inf} \cap \text{vacc})}{ P(\text{vacc})} = \frac{0.1}{0.5} = 0.2

and we can do the same for

P(infno vacc)=P(infno vacc)P( no vacc)=0.20.5=0.4P( \text{inf} | \text{no vacc} ) = \frac{P(\text{inf} \cap \text{no vacc})}{ P(\text{ no vacc})} = \frac{0.2}{0.5} = 0.4

We report back to our experimental team that our estimated probability of infection from someone who received a vaccine is 0.2 and the probability of infection from someone who did not received a vaccine is 0.4, double the probability of a vaccinated individual.

Conditional probabilities give us, for free, an alternative way to compute the probability of the intersection of two sets. All we need to do is rearrange the definition of conditional probability

P(AB)=P(AB)P(B)P(AB)=P(B)P(AB)\begin{align} P(A | B) &= \frac{P(A \cap B)}{P(B)} \\ P(A \cap B) &= P(B)P(A|B) \end{align}

The above equation is called the **multiplication rule. Lets explore how the multiplication rule may make computing probabilities easier.

Example: We want to compute the probability that it rains and we remember to leave the house with an umbrella. We can imagine our sample space having the following four outcomes: G\mathcal{G} = {(rain,remember),(rain,forgot), (no rain, remember), (no rain, forgot)}. We try to remember all the times that the outcome (rain,remember) occurred in our past---but we cannot. Instead, we can certainly estimate the probability we forgot our umbrella given that it rained because it was an unpleasant experience (for some). We estimate P(forgotrain)=0.95P(\text{forgot}|\text{rain}) = 0.95. To compute P(forgotrain)P(\text{forgot} \cap \text{rain}) all we need now is the probability it rains. We take a look at the weather station reports over the past year and use the frequentest approach to estimate the probability it rains:P(rain)=0.25P(\text{rain}) = 0.25. So then the probability it rains and we forget our umbrella is

P(forgotrain)=P(forgotrain)P(rain)=0.95×0.25=0.2375\begin{align} \begin{aligned} P(\text{forgot} \cap \text{rain}) &= P(\text{forgot}|\text{rain})P(\text{rain})\\ &=0.95 \times 0.25 = 0.2375 \end{aligned} \end{align}

The multiplication rule makes computations easier because we can think of events occurring in sequence. First it rains and second we forget our umbrella.

Conditional probabilities also allow us to express what it means for two events to be independent. An event AA is independent from an event BB if

P(AB)=P(A)P(A|B) = P(A)

We know the event BB occurred, but this has not changed the probability that AA has occurred. When two events are independent we can compute their intersection more easily.

Event A and B are independentP(AB)=P(AB)P(B)multiplication ruleP(AB)=P(A)P(B)independence\begin{align} \begin{aligned} &\text{Event } A \text{ and } B \text{ are independent}\\ &P(A \cap B) = P(A|B)P(B) &\text{multiplication rule}\\ &P(A \cap B) = P(A)P(B) &\text{independence}\\ \end{aligned} \end{align}

If two events are independent than the probability they occur together is the product of their probabilities. Statistical independence can be difficult to see.

Example We are recruited to track the evolution of an infectious agent for a team of public health officials (PHOs). To support future strategic planning the PHOs want to know the impact of intervention XX on increases or decreases in the incidence of this infectious agent. The PHO team collected for each county in their state whether the intervention was enacted, and whether the incidence of case counts of this infectious agent increased or decreased 60 days after the intervention was in place data.

InterventionRaise in infectionProbability
YesYes0.225
YesNo0.525
NoYes0.075
NoNo0.175

Table 1: Probabilities estimated from our data using a frequentest approach.

When we look at this table, our first thought may be that when the intervention is enacted there is a high probability that the infection rate decreases (0.525), evidence that this is an important intervention for preventing the spread of this agent.

But be careful. Let’s compute the probability of intervention P(intervention)P(\text{intervention}) where we define the event intervention as {(intervention,rise),(intervention,no rise)}\{ (\text{intervention},\text{rise}), (\text{intervention}, \text{no rise})\} and the probability of a raise in infection P(raise)P(\text{raise}) where the event raise is defined as {(intervention,rise),(no intervention,rise)}\{(\text{intervention},\text{rise}),(\text{no intervention}, \text{rise})\}. To do this we should define our sample space to be clear about what outcomes we can observe from our experiment.

Our sample space is the set of four pairs

G={(intervention,raise),(intervention,lower),(no intervention,raise),(no intervention,lower)}\begin{align} \begin{aligned} \mathcal{G}=\{ (\text{intervention},\text{raise}),(\text{intervention},\text{lower})\\ ,(\text{no intervention},\text{raise}) ,(\text{no intervention},\text{lower})\} \end{aligned} \end{align}

and we want to compute P(intervention)=0.225+0.525=0.75P(\text{intervention}) = 0.225 + 0.525 = 0.75 (why?) and P(raise)=0.225+0.075=0.30P(\text{raise}) = 0.225+0.075 = 0.30 (why?).

One way that can test whether intervention is independent of a rise or fall in incidence, is compare the probabilities we estimated from our data (in table \ref{tab.datafreq}) to the product of individual events we computed above. Lets look at an example. The probability of an intervention and rise in incidence was estimated from our data to be P(intervention,raise)=0.225P(\text{intervention},\text{raise}) = 0.225. Lets compare this probability to the product P(intervention)P(raise)P(\text{intervention}) \cdot P(\text{raise}).

P(intervention)P(raise)=0.750.30=0.225P(\text{intervention}) \cdot P(\text{raise}) = 0.75 \cdot 0.30 = 0.225

We have a match. Our estimated probability of an intervention and a rise occurring together is equal to the probability that an intervention occurs and a rise in incidence occurs. We can do the same procedure above for the remaining three scenario.

InterventionRaiseProbability from dataProbability assuming indep.
YesYes0.225(0.75 \times 0.30 = 0.225)
YesNo0.525(0.75 \times 0.70 = 0.525)
NoYes0.075(0.25 \times 0.30 = 0.075)
NoNo0.175(0.25 \times 0.70 = 0.175)

Table 1: Probabilities of the co-occurrence of an intervention and the rise or fall of an infectious agent, and the probability of each of these four events assuming they are independent.

We see that the probabilities we collected form the data match the product of the probabilities of each individual event. Intervention is independent, does not change the probability, of a rise or fall in incidence of the infectious agent we are tracking. We will need to report these results to the PHO team and recommend they try alternative interventions to curb the spread of this agent.

Random Variables

Introduction

The foundations of probability are built on sets, yet data is more naturally stored and more easily computed on if it is represented numerically.

Random variables match each outcome in our sample space to a value on the number line.

In addition to computational advantages, random variables help us extract from our data the most important characteristics, and they serve as building blocks which we can use to create powerful models. Random variables are also a language we can use to communicate our modeling efforts to other mathematicians, statisticians, and data scientists.

Suppose we hypothesize that the frequency of social media posts on some popular outlet are related to influenza-like illness~(ILI)---a syndromic diagnosis suggesting a patient may have influenza. A patient is diagnosed with ILI if their temperature is measured to be at or above 38C and symptoms resembling the flu. Because influenza is most active in winter and spring, we collect a random sample, each day, of social media posts from September to May and in addition we collect the proportion of patients who are admitted to the hospital and are diagnosed with influenza-like illness at the US national level.

The above hypothesis, data collection, and future inference has numerous details. However, we will see shortly that we can simplify our hypothesis by using random variables.

Maps from the sample space to the number line

Given a sample space G\mathcal{G}, a \textbf{random variable}, (e.g. XX), is a function from each element in G\mathcal{G}---from each outcome---to a value on the real number line. The real number line contains all numbers: integer and decimal, from negative to positive infinity.

\textbf{Example:} Suppose our sample space contains two elements G={a,b}\mathcal{G} = \{ a,b \}. We may decide to define a random variable XX that maps the outcome aa to the value -1 and the outcome bb to the value 1. In otherwords, X(a)=1X(a)=-1 and X(b)=1X(b)=1. We could as well define a random variable YY on the same sample space such that Y(a)=0Y(a)=0 and Y(b)=1Y(b)=1.

\textbf{Example:} Suppose our sample space contains all integers from 0 to 1000 G={0,1,2,3,1000}\mathcal{G} = \{0,1,2,3\cdots,1000 \}. We may be most interested in when an integer is even or odd, and so we can define a random variable Y(y)=0Y(y)=0 when yy, our outcome, is an odd integer and Y(y)=1Y(y)=1 when yy is even. This is an example of how a random variable can distill down a sample space with many outcomes into a random variable with two.

\textbf{Example:} Suppose we decide to study the relationship between the cumulative total number of cigarettes smoked by a person form the date that they started smoking and the presence of lung cancer. We define our sample space to be G={(x,y)xZ,y{0,1}}\mathcal{G} = \{ (x,y) | x \in \mathbb{Z}, y \in \{0,1\} \}. We define two random variables, a random variable XX that maps the outcome (x,y)(x,y) to the value in the first position xx, and a random variable YY that maps the outcome(x,y)outcome (x,y) to the value in the second position yy. Though our outcomes are linked, we can use random variables to think about two separate outcomes---cigarettes smoked and lung cancer---and how they interact.

How to assign probabilities to a random variable

Random variable themselves do not require that we include the probability of each of their values. Random variables are a function from outcomes to the real numbers---nothing more. That said, in practice we build random variables expecting that the probabilities we assign to outcomes in our sample space will correspond to probabilities assigned to values of our random variable.

We assign a probability to the value xx, which belongs in the support of random variable XX, the sum of the probabilities of all the outcomes that XX maps to xx.

P(X=x)=P(o1)+P(o2)++P(on)P(X=x) = P(o_{1}) + P(o_{2}) + \cdots + P(o_{n})

where each outcome o1,o2,,ono_{1},o_{2},\cdots,o_{n} is mapped by XX to the value xx. In other words, X(o)=xX(o)=x for each of o1,o2,,ono_{1},o_{2},\cdots,o_{n}.

\ex Define a S={a,b,c,d,e}\mathcal{S} = \{a,b,c,d,e\} and a random variable XX that maps the outcomes to the following values

OutcomeP(outcome)X(outcome)
a0.10
b0.251
c0.151
d0.32
e0.20

We assign the probability that X=0X=0 as the sum of the probabilities assigned to outcome aa and outcome ee, or

P(X=0)=P({a})+P({e})=0.1+0.2=0.3\begin{align} P(X=0) &= P(\{a\}) + P(\{e\})\\ &= 0.1+0.2 = 0.3 \end{align}

We can run the same procedure for all the elements in the support of XX,

P(X=1)=P({b})+P({c})=0.25+0.15=0.40P(X=2)=P({d})=0.3=0.30,\begin{align} P(X=1) &= P(\{b\}) + P(\{c\})\\ &= 0.25+0.15 = 0.40\\ P(X=2) &= P(\{d\}) = 0.3 = 0.30, \end{align}

and organize our work in a table

XP(X = x)
00.30
10.40
20.30

A \textbf{probability distribution} for a random variable XX is a set of tuples where the first position in each tuple is a value in the support of XX and the second position in the tuple is the corresponding probability assigned to that value.

\ex A probability distribution for the random variable XX above is {(0,0.30),(1,0.40),(2,0.30)}\{(0,0.30),(1,0.40),(2,0.30)\}.

\ex Imagine we run an experiment that collects data on marathon runners. We decide to collect the number of elapsed minutes until they finish the race. Our sample space is defined as all positive integers S={1,2,3,,}\mathcal{S} = \{1,2,3,\cdots,\}. We may decide to build a random variable XX that maps outcomes less than 60 to the value 1, outcomes from 61 to 120 to the value 2, and outcomes greater than 120 to the value 3. One potential probability distribution for XX is {(1,0.10),(2,0.50),(3,0.40)}\{(1,0.10),(2,0.50),(3,0.40)\}. For this probability distribution, P(X=1)=0.10P(X=1) = 0.10, P(X=2)=0.50P(X=2) = 0.50, and P(X=3)=0.40P(X=3) = 0.40.

Functionals of a random variable

There are times that we may wish to summarize the behavior of a random variable. One common way to describe how probability is distributed among values in the support of a random variable is by computing some function of that random variable.

Expectation

Suppose we build a random variable XX with a corresponding probability mass function fXf_{X}.

The \textbf{expected value} of a random variable XX is computed as

E(X)=P(X=x1)x1+P(X=x2)x2++P(X=xn)xn=f(x1)x1+f(x2)x2++f(xn)xn\begin{align} \mathbb{E}\left(X \right) &= P(X=x_{1})x_{1} +P(X=x_{2})x_{2} + \cdots + P(X=x_{n})x_{n}\\ &= f(x_{1})x_{1} + f(x_{2})x_{2} + \cdots + f(x_{n})x_{n} \end{align}

where x1,x2,,xnx_{1},x_{2},\cdots,x_{n} are all values in the supp(X)supp(X).

An intuitive definition of the expected value is that E(X)\mathbb{E}(X) is a weighted average of all values in the support of XX where the weight for xix_{i} is the probability of xix_{i}. The expected value of XX will be close to values in supp(X)supp(X) with high probability.

Example Build a random variable YY with support supp(Y)={1,0,1}supp(Y) = \{-1,0,1\} and fY={(1,0.2),(0,0.5),(1,0.3)}f_{Y} = \{(-1,0.2),(0,0.5),(1,0.3)\}. The expected value of YY is E(Y)=0.2(1)+0.5(0)+0.3(1)=0.1\mathbb{E}(Y) = 0.2 (-1) + 0.5 (0) + 0.3 (1) = 0.1.

Homework

  1. Increasing your plot (earnings) in life:Suppose you decide to play a game of chance. The game costs 2 dollars, and when you spend 2 dollars “the house” will roll a single die. Before they roll the die, you get to choose from one of three options for how to determine a win. Choice A assigns you a win if the die lands on a 4,5, or 6. The payout you get is 2 dollars. Choice B assigns you a win if the die lands on a 6. The payout is 10 dollars. Choice C assigns you a win if the die lands on a 2,3,4,5,6. The payout is 2.50 dollars. (a) Please construct three random variables: WaW_{a}, WbW_{b}, and WcW_{c}. The random varable WaW_{a} will map a winning die roll to the net winnings defined as the amount of money you would win minus the cost of playing the game for game choice A. WbW_{b} maps a due roll to net winnings for choice B, and WcW_{c} for choice c. (b) Please compute the expected value for WaW_{a}, WbW_{b}, and WcW_{c}. (c) Please discuss briefly what choice you should make: A, B, or C.

  2. Plotting Crime: Please read the article titled “Robbing banks: Crime does pay – but not very much” linked here Reilly et al. (2012). In this article on page 3/5 there is an orange box with an equation that estimates the Penalty that would make a criminal indifferent to robbing a bank. They find that the expected next benefit is vqR(1q)PvqR - (1-q)P. Using “And” and “OR” rules, can you please describe this mathemtical equation in words to someone who we assume hasn’t learned about probability.

  3. Plotting and Natural Language Processing: Please read the poem by Emily Dickinson titled Luck is not Chance https://poets.org/poem/luck-not-chance-1350. Suppose we number the lines from top to bottom as 1,2,3, ... 7. Our experiment will select at random a single word from this poem. Please estimate the probability of selecting line 3. Please estimate the probability of selecting a word with more than 5 letters.

  4. Conditional probability - NLP part two: Suppose we tell you that the when we chose at random, we chose a word in the first three lines of the poem. Please compute the probability of selecting a word with more than 5 letters given that word appeared in the first three lines. Why is this conditional probability different than the probability of selecting a word with 5 letters over the whole poem?

References
  1. Reilly, B., Rickman, N., & Witt, R. (2012). Robbing Banks. Significance, 9(3), 17–21. 10.1111/j.1740-9713.2012.00570.x