# FA17 Lecture 8

($1)$2 | $3 ($4) | $5 ($6)

# Lecture 8: Random variables

• Reading: Cameron [[../handouts/cameron_prob_notes.pdf#page=47|3.1–3.2, 3.4]], MCS [[../handouts/mcs.pdf#page=823|19.1]]
• [[../../2016fa/lectures/2800probability.pdf|Last semester's notes]]
• definitions: random variable, PMF, joint PMF, sum/product/etc of RVs, indicator variable, expectation

## Random variables

Definition: A (real-valued) random variable is just a function .

Example: Suppose I roll a fair 6-sided die. On an even roll, I win \$10. On an odd roll, I lose however much money is shown. We can model the experiment (rolling a die) using the sample space and an equiprobable measure. The result of the experiment is given by the random variable given by , , , , , and .

Definition: Given a random variable and a real number , the poorly-named event is defined by .

This definition is useful because it allows to ask "what is the probability that ?"

Definition: The probability mass function (PMF) of is the function given by .

## Combining random variables

Given random variables and on a sample space , we can combine apply any of the normal operations of real numbers on and by performing them pointwise on the outputs of and . For example, we can define by . Similarly, we can define by .

We can also consider a real number as a random variable by defining by . We will use the same variable for both the constant random variable and for the number itself; it should be clear from context which we are referring to.

## Indicator variables

We often want to count how many times something happens in an experiment.

Example: Suppose I flip a coin 100 times. The sample space would consist of sequences of 100 flips, and I might define the variable to be the number of heads. For example, , while .

A useful tool for counting is an indicator variable:

Definition: The indicator variable for an event is a variable having value 1 if the happens, and 0 otherwise.

The number of times something happens can be written as a sum of indicator variables.

In the coin example, we could define an indicator variable which is 1 if the first coin is a head, and 0 otherwise (e.g. ). We could define a variable that only looks at the second toss, and so on. Then as defined above can be written as . This is useful because (as we'll see when we talk about expectation) it is often easier to reason about a sum of simple variables (like ) than it is to reason about a complex variable like .

## Joint PMF of two random variables

We can summarize the probability distribution of two random variables and using a "joint PMF". The joint PMF of and is a function from and gives for any and , the probability that and . It is often useful to draw a table:

y

1

10

x

1

1/3

1/6

10

1/6

1/3

Note that the sum of the entries in the table must be one (Exercise: prove this). You can also check that summing the rows gives the PMF of , while summing the columns gives the PMF of .

## Expectation

The "expected value" is an estimate of the "likely outcome" of a random variable. It is the weighted average of all of the possible values of the RV, weighted by the probability of seeing those outcomes. Formally:

Definition: The expected value of , written is given by

Claim: (alternate definition of )

Proof sketch: this is just grouping together the terms in the original definition for the outcomes with the same value.

Note: You may be concerned about ". In discrete examples, almost everywhere, so this sum reduces to a finite or at least countable sum. In non-discrete example, this summation can be replaced by an integral. Measure theory is a branch of mathematics that puts this distinction on firmer theoretical footing by replacing both the summation and the integral with the so-called "Lebesgue integral". In this course, we will simply use "" with the understanding that it becomes an integral when the random variable is continuous.