Random variables
Theory
Theory 1
Random variable
A random variable (RV) on a probability space is a function .
So assigns to each outcome a number.
Note: The word ‘variable’ indicates that an RV outputs numbers.
Random variables can be formed from other random variables using mathematical operations on the output numbers.
Given random variables and , we can form these new ones:
Suppose is some particular outcome. Then, for example, is by definition .
Random variables determine events.
- Given , the event “” is equal to the set
- That is: the set of outcomes mapped to by
- That is: the event “ took the value ”
Such events have probabilities. We write them like this:
This generalized to events where lies in some range or set, for example:
The axioms of probability translate into rules for these events.
For example, additivity leads to:
A discrete random variable has probability concentrated at a discrete set of real numbers.
- A ‘discrete set’ means finite or countably infinite.
- The distribution of probability is recorded using a probability mass function (PMF) that assigns probabilities to each of the discrete real numbers.
- Numbers with nonzero probability are called possible values.
PMF
The PMF function , for a discrete RV, is defined by:
A continuous random variable has probability spread out over the space of real numbers.
- The distribution of probability is recorded using a probability density function (PDF) which is integrated over intervals to determine probabilities.
The PDF function for (a CRV) is written for , and probabilities are calculated like this:
For any RV, whether discrete or continuous, the distribution of probability is encoded by a function:
CDF
The cumulative distribution function (CDF) for a random variable is defined for all by:
Notes:
- Sometimes the relation to is omitted and one sees just “.”
- Sometimes the CDF is called, simply, “the distribution function” because:
The CDF works for a discrete, continuous, or mixed RV
- PMF is for discrete only
- PDF is for continuous only
- CDF covers both and covers mixed RVs
The CDF of a discrete RV is always a stepwise increasing function. At each step up, the jump size matches the PMF value there.
From this graph of :
we can infer the PMF values based on the jump sizes:
For a discrete RV, the CDF and the PMF can be calculated from each other using formulas.
Link to originalPMF from CDF
Given a PMF , the CDF is determined by:
where is the set of possible values of .
Illustration
Example - PDF and CDF: Roll 2 dice
PDF and CDF: Roll 2 dice
Roll two dice colored red and green. Let record the number of dots showing on the red die, the number on the green die, and let be a random variable giving the total number of dots showing after the roll, namely .
- Find the PMFs of and of and of .
- Find the CDF of .
- Find .
Solution
(1) Construct sample space:
Denote outcomes with ordered pairs of numbers , where is the number showing on the red die and is the number on the green one.
Therefore are integers satisfying .
(2) Create chart of outcomes:
(3) Define random variables:
We have and .
Therefore .
(4) Find PMF of :
Use variable for each possible value of , so . Find :
Therefore for every .
(5) Find PMF of similarly:
(6) Find PMF of :
Count outcomes along diagonal lines in the chart.
2 3 4 5 6 7 8 9 10 11 12
Evaluate: .
(7) Find CDF of :
CDF definition:
Apply definition: add new PMF value at each increment:
Link to original
Example - Total heads count; binomial expansion of 1
PMF for total heads count; binomial expansion of 1
A fair coin is flipped times.
Let be the random variable that counts the total number of heads in each sequence.
The PMF of is given by:
Since the total probability must add to 1, we know this formula must hold:
Is this equation really true?
There is another way to view this equation: it is the binomial expansion where and :
Link to original
Example - Life insurance payouts
Life insurance payouts
A life insurance company has two clients, and , each with a policy that pays $100,000 upon death. Consider events that the older client dies next year, and that the younger dies next year. Suppose and .
Define a random variable measuring the total money paid out next year in units of $1,000. The possible values for are 0, 100, 200. Now calculate:
Link to original
Bernoulli process
Theory - Bernoulli, binomial, geometric, Pascal, uniform
Theory 1 - Bernoulli, binomial, geometric, Pascal, uniform
In a Bernoulli process, an experiment with binary outcomes is repeated; for example flipping a coin repeatedly. Several discrete random variables may be defined in the context of some Bernoulli process.
Notice that the sample space of a Bernoulli process is infinite: an outcome is any sequence of trial outcomes, e.g.
Bernoulli variable
A random variable is a Bernoulli indicator, written , when indicates whether a success event, having probability , took place in trial number of a Bernoulli process.
Bernoulli PMF:
Here .
An RV that always gives either or for every outcome is called an indicator variable.
Binomial variable
A random variable is binomial, written , when counts the number of successes in a Bernoulli process, each having probability , over a specified number of trials.
Binomial PMF:
- For example, if , then gives the odds that success happens exactly 5 times over 10 trials, with probability of success for each trial.
- In terms of the Bernoulli indicators, we have:
- If is the success event, then is the success probability, and is the failure probability.
Geometric variable
A random variable is geometric, written , when counts the discrete wait time in a Bernoulli process until the first success takes place, given that success has probability in each trial.
Geometric PMF:
Here .
- For example, if , then gives the probability of getting: failure on the first trials AND success on the trial.
Pascal variable
A random variable is Pascal, written , when counts the discrete wait time in a Bernoulli process until success happens times, given that success has probability in each trial.
Pascal PMF:
- For example, if , then gives the probability of getting: the success on (precisely) the trial.
- Interpret the formula: ways to arrange successes among ‘prior’ trials, times the probability of exactly successes and failures in one specific sequence.
- The Pascal distribution is also called the negative binomial distribution, e.g. .
Link to originalUniform variable
A discrete random variable is uniform on a finite set , written , when the probability is a fixed constant for outcomes in and zero for outcomes outside .
Discrete uniform PMF:
Continuous uniform PDF:
Illustration
Example - Roll die until
Roll die until
Roll a fair die repeatedly. Find the probabilities that:
(a) At most 2 threes occur in the first 5 rolls.
(b) There is no three in the first 4 rolls, using a geometric variable.
Solution
(a)
(1) Label variables and events:
Use a variable to count the number of threes among the first six rolls.
Seek as the answer.
(2) Calculations:
Divide into exclusive events:
(b)
(1) Label variables and events:
Use a variable to give the roll number of the first time a three is rolled.
Seek as the answer.
(2) Compute:
Sum the PMF formula for :
(3) Recall geometric series formula:
For any geometric series:
Therefore:
Link to original
Example - Cubs winning the World Series
Cubs winning the World Series
Suppose the Cubs are playing the Yankees for the World Series. The first team to 4 wins in 7 games wins the series. What is the probability that the Cubs win the series?
Assume that for any given game the probability of the Cubs winning is and losing is .
Solution
Method (a): We solve the problem using a binomial distribution.
(1) Label variables and events:
Use a variable . This counts the number of wins over 7 games. Thus, for example, is the probability that the Cubs win exactly 4 games over 7 played.
Seek as the answer.
(2) Calculate using binomial PMF:
Insert data:
Compute:
Convert :
Method (b): We solve the problem using a Pascal distribution instead.
(1) Label variables and events:
Use a variable . This measures the discrete wait time until the win. Thus, for example, is the probability that the Cubs win their game on game number .
Seek as the answer.
(2) Calculate using Pascal PMF:
Insert data:
Compute:
Convert :
Notice: The calculation seems very different than method (a), right up to the end!
Link to original
Expectation and variance
Theory - Expectation and variance
Theory 1
Expected value
The expected value of random variable is the weighted average of the values of , weighted by the probability of those values.
Discrete formula using PMF:
Continuous formula using PDF:
Notes:
- Expected value is sometimes called expectation, or even just mean, although the latter is best reserved for statistics.
- The Greek letter is also used in contexts where ‘mean’ is used.
Let be a random variable, and write .
Variance
The variance measures the average squared deviation of from . It estimates how concentrated is around .
- Defining formula:
- Shorter formula:
Calculating variance
- Discrete formula using PMF:
- Continuous formula using PDF:
Link to originalStandard deviation
The quantity is called the standard deviation of .
Illustration
Example - Tokens in bins
Gambling game - tokens in bins
Consider a game like this: a coin is flipped; if then draw a token from Bin 1, if then from Bin 2.
- Bin 1 contents: 1 token $1,000, and 9 tokens $1
- Bin 2 contents: 5 tokens $50, and 5 tokens $1
It costs $50 to enter the game. Should you play it? (A lot of times?) How much would you pay to play?
Solution
(1) Setup:
Let be a random variable measuring your winnings in the game.
The possible values of are 1, 50, and 1000.
(2) Find the PDF of :
For have
For have
For have
These add to 1, and for all other .
(3) Find using the discrete formula:
Since , if you play it a lot at $50 you will generally make money.
Challenge Q:
Link to original
If you start with $200 and keep playing to infinity, how likely is it that you go broke?

Example - Expected value: rolling dice
Expected value: rolling dice
Let be a random variable counting the number of dots given by rolling a single die.
Then:
Let be an RV that counts the dots on a roll of two dice.
The PMF of :
Then:Notice that .
In general, .
Let be a green die and a red die.
From the earlier calculation, and .
Since , we derive by simple addition!
Link to original
Example - Expected value by finding new PMF
Expected value by finding new PMF
Let have distribution given by this PMF:
Find .Solution
(1) Compute the PMF of :
PMF arranged by possible value:
(2) Calculate the expectation:
Using formula for discrete PMF:
Link to original
Exercise - Variance using simplified formula
Variance for composite using PMF and simpler formula
Suppose has this PMF:
1 2 3 Find using the formula with .
(Hint: you should find and along the way.)
Link to original
Discrete families summary
Theory
Theory 1
Bernoulli:
- Indicates a win.
Binomial:
- Counts number of wins.
Geometric:
- Counts discrete wait time until first win.
Pascal:
- Counts discrete wait time until win.
Poisson:
Link to original
- Counts “arrivals” during time interval.





