






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Discrete random variables, their definition, probability mass function, and expectation. It includes examples of discrete random variables, such as the number of heads in coin flips, and calculates their probability mass functions and expectations. The document also explains the concept of independent events and how it applies to discrete random variables.
Typology: Study notes
1 / 10
This page cannot be seen from the preview
Don't miss anything!







(From “Probability & Statistics with Applications to Computing” by Alex Tsun)
Suppose you flip a fair coin twice. Then the sample space is:
Ω = {HH, HT, T H, T T }
Sometimes, though, we don’t care about the order (HT vs T H), but just the fact that we got one heads and one tail. So we can define a random variable as a numeric function of the outcome.
For example, we can define X to be the number of heads in the two independent flips of a fair coin. Then X is a function, X : Ω → R which takes outcomes ω ∈ Ω and maps them to a number. For example, for the outcome HH, we have X(HH) = 2 since there are two heads. See the rest below!
X is an example of a random variable, which brings us to the following definition:
Definition 3.1.1: Random Variable
Suppose we conduct an experiment with sample space Ω. A random variable (rv) is a numeric function of the outcome, X : Ω → R. That is, it maps outcomes (ω ∈ Ω) to numbers: ω 7 → X(ω). The set of possible values X can take on is its range/support, denoted ΩX. If ΩX is finite or countably infinite (typically integers or a subset), X is a discrete random variable (drv). Else if ΩX is uncountably large (the size of real numbers), X is a continuous random variable.
2 Probability & Statistics with Applications to Computing 3.
Example(s)
Below are some descriptions of random variables. Find their ranges and classify them as a discrete random variable (DRV) or continuous random variable (CRV). The first row is filled out for you as an example!
RV Description Range DRV or CRV? X, the # of heads in n flips of a fair coin { 0 , 1 ,... , n} DRV N , the # of people born this year. TODO TODO F , the # of flips of a fair coin up to and including my first head. TODO TODO B, the amount of time I wait for the next bus in seconds. TODO TODO C, the temperature in Celsius of liquid water TODO TODO
Solution Here is the solution in a table, with explanations below.
RV Description Range DRV or CRV? X, the # of heads in n flips of a fair coin { 0 , 1 ,... , n} DRV N , the # of people born this year. { 0 , 1 , 2 ,... } DRV F , the # of flips of a fair coin up to and including my first head. { 1 , 2 ,... , } DRV B, the amount of time I wait for the next bus in seconds. [0, ∞) CRV C, the temperature in Celsius of liquid water (0, 100) CRV
Let’s return to X which we defined to be the number of heads in the flip of two fair coins. We already determined that Ω = Ω = {HH, HT, T H, T T } and X(HH) = 2, X(HT ) = 1, X(T H) = 1 and X(T T ) = 0. The range, ΩX , is { 0 , 1 , 2 }.
4 Probability & Statistics with Applications to Computing 3.
must choose 9 as one of the balls, and the other 2 from 1-8. So we have
pY (k) =
(k− 1 2
3
) , k ∈ ΩY
In our next example, we will briefly introduce one more concept called the CDF of a random variable. We will discuss it a lot more in depth in 4.1 when we discuss continuous RVs!
Example(s)
Suppose there are three students, and their hats are returned randomly with each of the 3! permuta- tions equally likely. Let X be the number of hats returned to the correct owner.
Solution
ω X(ω) P (ω) Explanation 123 3 1 / 6 All 3 people got their hat back. 132 1 1 / 6 Only person 1 got their hat back. 213 1 1 / 6 Only person 3 got their hat back. 231 0 1 / 6 No one got their hat back. 312 0 1 / 6 No one got their hat back. 321 1 1 / 6 Only person 2 got their hat back.
Note that it isn’t possible for X to equal 2: if 2 people out of 3 have their hat back, then the third person must also have their own hat! So ΩX = { 0 , 1 , 3 }. Let’s work on each:
ω∈Ω:X(ω)=0 P^ (ω) =^ P^ (231) +^ P^ (312) =^
1 6 +^
1 6 =^
2
ω∈Ω:X(ω)=1 P^ (ω) =^ P^ (132) +^ P^ (213) +^ P^ (321) =^
1 6 +^
1 6 +^
1 6 =^
3
ω∈Ω:X(ω)=3 P^ (ω) =^ P^ (123) =^
1
So our final PMF is:
pX (k) =
2 / 6 k = 0 3 / 6 k = 1 1 / 6 k = 3
3.1 Probability & Statistics with Applications to Computing 5
Putting this all together gives:
FX (t) =
0 t < 0 2 / 6 0 ≤ t < 1 5 / 6 1 ≤ t < 3 1 t ≥ 3 See the picture below for a plot of the PMF and CDF!
You’ll notice the CDF is always between 0 and 1 because it is a probability! It is always increasing as well, since we are only adding more and more cumulative probabilities (which are nonnegative). Notice at the jumps of the CDF, the vertical distance is just the PMF (why?)! Again, we’ll talk more about CDFs in 4.1, so treat this as foreshadowing!
We have this idea of a random variable, which is actually neither random nor a variable (it’s a deterministic function X : Ω → ΩX .) However, the way I like to think about it is: it a random quantity which we do
3.1 Probability & Statistics with Applications to Computing 7
the correct owner.” The range was ΩX = { 0 , 1 , 3 } and PMF was
pX (k) =
2 / 6 k = 0 3 / 6 k = 1 1 / 6 k = 3
Find the expected number of people who get their hat back, E [X].
Solution Typically, the second definition of expectation is easier to use since it has less terms to sum over. We take the sum of each value in ΩX multiplied by its probability.
E [X] =
k∈{ 0 , 1 , 3 }
k · pX (k) = 0 ·
That is, if we return 3 hats randomly to the 3 students, we expect on average that 1 student will get their own hat back. It turns out that, no matter how many students/hats there are, the answer is always 1; how amazing! We’ll actually show this amazing fact in section 3.3, so stay tuned!
Example(s)
There are 3 people in Linbo’s family; his mom, dad, and sister. Each family member decides whether or not they want to come to lunch in his social-distancing home restaurant, independently of the others.
Unfortunately, if all 3 of them want to come, he must turn one of them away since the restaurant capacity is 2 guests. Otherwise, he will take everyone that comes. Let X be the number of customers that Linbo serves at lunch.
Solution
pX (0) = P (X = 0) = P
The probability that exactly one person comes has three cases: only mom comes, only dad comes, or only sister comes:
pX (1) = P (X = 1) = P
8 Probability & Statistics with Applications to Computing 3.
Finally, for pX (2), we have some work to do. We can sum over the three cases where exactly 2 of the 3 want to come. But if all 3 want to come (P (M, D, S)), this also counts as X = 2 since we turn one of them away! So we actually add 4 probabilities to get pX (2). Alternatively, we know that these three probabilities must sum to 1: pX (0) + pX (1) + pX (2) = 1, and hence using our previous computations:
pX (2) = 1 − pX (0) − pX (1) = 1 − 0. 072 − 0 .404 = 0. 524
So our PMF is:
pX (k) =
The expectation is
E [X] =
k∈ΩX
k · pX (k) = 0 · 0 .072 + 1 · 0 .404 + 2 · 0 .524 = 1. 452
So we expect 1.452 people to come!
E [P ] = E [10X − 50] = 10E [X] − 50 = 14. 52 − 50 = − 35. 48
But is this step valid: E [10X − 50] = 10E [X] − 50? Yes, and it is called linearity of expectation! This is one of the most important theorems on expectation, and is covered in the next section.
The “proper” way to do this expectation right now is to start over and find the range, PMF, and expectation of P. That is, ΩP = {− 50 , − 40 , − 30 } since these are the possible profits if 0, 1, or 2 people came. Then,
pP (k) =
Solution: The range is ΩX = { 1 , 2 , 3 , 4 , 5 , 6 }. The PMF is
pX (k) =
, k ∈ ΩX
The expectation is
E [X] =
k∈ΩX
k · pX (k) = 1 ·
This kind of makes sense right? You expect the “middle number” between 1 and 6, which is 3.5.
10 Probability & Statistics with Applications to Computing 3.
10? And if p = 1/7, maybe 7? So seems like our guess will be E [X] = (^1) p. It turns out this intuition is actually correct!
E [X] =
k∈ΩX
k · pX (k) [def of expectation]
k=
k(1 − p)k−^1 p
= p
k=
k(1 − p)k−^1 [p is a constant with respect to k ]
= p
k=
d dp
(−(1 − p)k)
d dy
yk^ = kyk−^1
= −p
d dp
k=
(1 − p)k−^1
[swap sum and integral]
= −p
d dp
1 − (1 − p)
geometric series formula:
i=
ri^ =
1 − r
= −p
d dp
p
= −p
p^2
p