Chapter 8 - Discrete Random Variables

advertisement
S1: Chapter 8
Discrete Random Variables
www.drfrostmaths.com
Dr J Frost (jfrost@tiffin.kingston.sch.uk)
Last modified: 12th January 2016
Variables and Random Variables
In Chapter 2, we saw that just like in algebra, we can use a variable to represent
some quantity, such as height.
i.e. It is just like a variable in statistics,
except each outcome has now been
assigned a probability.
! A random variable 𝑿 represents a single
experiment/trial. It consists of outcomes with
a probability for each.
𝒙
1
𝑷(𝑿 = 𝒙) 0.3
2
3
4
5
6
0.2
0.1
0.25
0.05
0.1
𝑃(𝑋 = π‘₯)
“The probability that…
…the outcome of the
random variable 𝑋…
i.e. 𝑋 is a random variable (capital
letter), but π‘₯ is a particular outcome.
…was the specific
outcome π‘₯”
A shorthand for 𝑃 𝑋 = π‘₯ is ! 𝑝 π‘₯ (note the lowercase 𝑝).
It’s like saying “the probability that the outcome of my coin throw was heads”
(𝑃(𝑋 = β„Žπ‘’π‘Žπ‘‘π‘ )) vs “the probability of heads” (𝑝(β„Žπ‘’π‘Žπ‘‘π‘ )). In the latter the coin
throw was implicit.
Is it a discrete random variable?
The height of a person
randomly chosen.
The number of cars that
pass in the next hour.
The number of countries in
the world.
No
οƒΌ
Yes

This is a continuous random variable.
No

Yes
οƒΌ
No
οƒΌ
Yes

It does not vary, so is not a variable!
Probability Distributions vs Probability Functions
There are two ways to write the mapping from outcomes to probabilities.
The “{“ means we have a ‘piecewise function’.
This just simply means we choose the
function from a list depending on the input.
Probability Functions
𝑝 π‘₯ =
0.1π‘₯,
0,
π‘₯ = 1,2,3,4
π‘œπ‘‘β„Žπ‘’π‘Ÿπ‘€π‘–π‘ π‘’
e.g. if π‘₯ = 2, then
the probability is
0.1 × 2 = 0.2
Advantages of probability function:
Can have a rule/expression based on the outcome.
Particularly for continuous random variables (in S2), it
would be impossible to list the probability for every
outcome. More compact.
?
Probability Distribution
𝒙
𝒑(𝒙)
1
2
0.1
0.2
3
?0.3
4
0.4
The table form that you know and love.
Advantages of distribution:
Probability for each outcome more explicit.
?
Example
The random variable 𝑋 represents the number of heads when
three coins are tossed.
Underlying
Sample Space
{ HHH,
HHT,
HTT,
HTH,
THH, ?
THT,
TTH,
TTT }
Probability Distribution
Num heads 𝒙
𝑷(𝑿 = 𝒙)
0
1
1
8
?
Probability Function
?
2
3
8
3
3
8
1
8
Exam Question
Edexcel S1 May 2012
(Hint: Use your knowledge
that Σ𝑝 … = 1)
p(-1) = 4k, p(0) = k, p(1) = 0, p(2) = k
And since Σ𝑝 π‘₯ = 1, 4k + k + 0 + k = 6k = 1
?
1
Therefore π‘˜ =
6
Exercise 8A
5
The random variable X has a probability function
𝑃 𝑋 = π‘₯ = π‘˜π‘₯ π‘₯ = 1,2,3,4.
1
Show that π‘˜ =
10
7
The random variable X has a probability function:
where k is a constant.
a) Find the value of k.
b) Construct a table giving the probability distribution of 𝑋.
7a) k = 0.125
7b)
?
x
1
2
P(X = x)
0.125
0.125
3
4
0.375
0.375
Probabilities of ranges of values
1
π‘₯
𝑃(𝑋 = π‘₯) 0.1
2
0.2
3
0.3
4
0.25
?
𝑃 1 < 𝑋 < 5 = 0.75
?
𝑃 2 ≤ 𝑋 ≤ 4 = 0.75
𝑃 3 < 𝑋 ≤ 6 = 0.4?
𝑃 𝑋 ≤ 3 = 0.6 ?
5
0.1
6
0.05
Cumulative Distribution Function (CDF)
How could we express “the
probability that the age of someone
is at most 40”?
? 40
𝑃 𝐴≤
𝐹 40?
F is known as the cumulative
distribution function, where
𝐹 π‘₯ =𝑃 𝑋≤π‘₯
(note the capital F)
If X is the number of heads
thrown in 2 throws...
0
π‘₯
𝑃(𝑋 = π‘₯) 0.25
?
0
π‘₯
𝐹(π‘₯) 0.25
?
1
0.5?
1
0.75
?
2
0.25
?
2
1 ?
Example
The discrete random variable X has a cumulative distribution function
𝐹(π‘₯) defined by:
𝐹 π‘₯ =
a
π‘₯+π‘˜
;
8
x = 1, 2 and 3
Find the value of k.
F(3) = 1. Thus
? k = 5.
b Draw the distribution table for the cumulative distribution function.
x
F(x)
c
1
3/4?
2
7/8?
3
1 ?
Write down F(2.6)
F(2.6) = F(2)
? = 7/8
d Find the probability distribution of X.
x
1
P(X=x) 3/4?
2
3
1/8?
1/8?
CDF
F(x)
p(x)
1
Shoe Size (x)
?
Shoe Size (x)
It’s just like how we’d turn a frequency graph
into a cumulative frequency graph.
Exam Questions
Edexcel S1 May 2013 (R)
= 0.4
?
x
1
2
P(X = x)
0.4
? 0.25
3
0.35
Edexcel S1 Jan 2013
F(3) = 1, so (27 +?k)/40 = 1, ...
x
1
P(X = x)
0.35
?
2
3
0.175
0.475
Exercise 8B
Q5-8
Expected Value, E[X]
Suppose that we throw a single fair die 60 times, and see the following outcomes:
π‘₯
1
2
3
4
5
6
𝑃(𝑋 = π‘₯)
1
6
1
6
1
6
1
6
1
6
1
6
Throw a lot of times.
π‘₯
Frequency
1
2
3
4
5
6
9
11
10
8
12
10
𝒙 = πŸ‘. πŸ“πŸ“?
What is the mean outcome based on our sample?
But using the actual probabilities of each outcome (i.e. 1/6 for each), what would
we expect the average outcome to be?
3.5
?
! If 𝑋 is the random variable, 𝑬(𝑿) is known as the expected value of 𝑋.
𝐸 𝑋 =
π‘₯ 𝑝(π‘₯)
It represents the mean outcome we would expect if we were to do our experiment
lots of times.
𝟏
𝟏
𝟏
𝟏
𝟏
𝟏
For our fair die: 𝑬 𝑿 = 𝟏 × πŸ” + 𝟐 × πŸ” + πŸ‘ × πŸ” + πŸ’
? × πŸ” + πŸ“ × πŸ” + πŸ” × πŸ” = πŸ‘. πŸ“
Quickfire E[X]
Find the expected value of the following distributions (in your head!).
𝒙
𝒑(𝒙)
𝒙
1
2
3
0.1
0.6
0.3
𝑷(𝑿 = 𝒙)
4
6
8
0.5
0.25
0.25
𝐸 𝑋 = 5.5?
𝐸 𝑋 = 2.2?
Bro Tip: Suppose you treated the probabilities as
frequencies then found the mean of the ‘frequency
table’. What do you notice?
𝒙
10
𝑷(𝑿 = 𝒙)
20
1
4
30
1
2
1
4
𝐸 𝑋 = 20 ?
Bro Tip: If the distribution is ‘symmetrical’, i.e. both the
outcomes and probabilities are symmetrical about the centre,
then the expected value is this central value.
Harder Example
𝒙
𝑷 𝑿=𝒙
1
2
0.1
3
𝑝
4
0.3
5
π‘ž
0.2
Given that 𝐸 𝑋 = 3, find the values of 𝑝 and π‘ž.
Probabilities add to 1:
Expected value:
𝒑 + 𝒒 + 𝟎. 𝟏 + 𝟎. πŸ‘ + 𝟎. 𝟐 = 𝟏
𝟎.
? 𝟏 + πŸπ’‘ + 𝟎. πŸ— + πŸ’π’’ + 𝟏 = πŸ‘
Hint: Can you think of TWO ways we could get an equation relating 𝑝 and
π‘ž?
Solving simultaneous equations:
𝒑 = 𝟎. πŸ‘, 𝒒 = 𝟎. 𝟏
To 𝐸 𝑋 2 and beyond
Remember with the mean for a sample, we could find the “mean of the squares”
when finding variance, e.g.
Σ𝑓π‘₯ 2
?
Σ𝑓
We just replaced each value π‘₯ with its square.
Unsurprisingly the same applies for the expected value of a random variable.
Just replace π‘₯ with whatever is in the square brackets. Sorted!
𝒙
𝑷 𝑿=𝒙
1
2
3
0.1
0.5
0.4
𝐸 𝑋 2 = 12 × 0.1 + 22 × 0.5? + 32 × 0.4 = 5.7
𝐸 2𝑋 = 2 × 0.1 + 4 × 0.5 ?+ 6 × 0.4 = 4.6
Variance
We know how to find it for experimental data. How about for a random variable?
Mean of the Squares
π‘‰π‘Žπ‘Ÿ 𝑋 = 𝐸
Minus
2
?
𝑋
𝒙
𝑷 𝑿=𝒙
Square of the Mean
𝐸
–?
1
2
3
0.1
0.5
0.4
2
?
𝑋
(We already
worked out that
𝐸 𝑋 2 = 5.7)
π‘‰π‘Žπ‘Ÿ 𝑋 = πŸ“. πŸ• − 𝟐. πŸ‘?𝟐 = 𝟎. πŸ’πŸ
Exam Questions
Edexcel S1 May 2010
a = 1/4
?
=1?
E[X2] = 3.1
2 = 2.1
So Var[X]
=
3.1
–
1
?
Edexcel S1 Jan 2009
?= 1
= P(X <= 1.5) = ?
P(X <= 1) = 0.7
E[X2] = 2. So Var[X]
? = 2 – 12 = 1
Exercise 8D
Coding!
Oh dear god, not again...
Recap
Suppose that we have a list of peoples heights x. The mean height is 1.5m and
the variance 0.2m.
We use the coding π’š = πŸ‘π’™ – 𝟏𝟎:
𝑦 = −5.5?
πœŽπ‘¦2 = 1.8 ?
It’s no different with expected values. What do we expect these to be in terms
of the original expected value E[X] and the original variance Var[X]?
E[X + 10] = E[X]?+ 10
E[3X] = 3E[X]
?
?
Var[3X] = 9Var[X]
Adding 10 to all values adds
10 to the expected value.
Quickfire Coding
Express these in terms of the original 𝐸 𝑋 and π‘‰π‘Žπ‘Ÿ 𝑋 .
𝐸 4𝑋 + 1 = 4𝐸 𝑋 ? + 1
𝐸 1 − 𝑋 = 1 − 𝐸? 𝑋
? 𝑋
π‘‰π‘Žπ‘Ÿ 4𝑋 = 16π‘‰π‘Žπ‘Ÿ
π‘‰π‘Žπ‘Ÿ 𝑋 + 1 = π‘‰π‘Žπ‘Ÿ ?𝑋
? 𝑋
π‘‰π‘Žπ‘Ÿ 3𝑋 + 2 = 9π‘‰π‘Žπ‘Ÿ
𝑋−1
𝐸 𝑋 −1
?
𝐸
=
2
2
𝑋−1
1
π‘‰π‘Žπ‘Ÿ
= π‘‰π‘Žπ‘Ÿ? 𝑋
2
4
Exercise 8E
2 E[X] = 2, Var[X] = 6
Find
a) E[3X] = 3E[X]?= 6
d) E[4 – 2X] = 4 – 2E[X]
? =0
f) Var[3X + 1] = 9Var[X]
? = 54
5 The random variable Y has mean 2 and variance 9.
Find:
a) E[3Y+1] = 3E[Y] ?
+1=7
c) Var[3Y+1] = 9Var[Y]
? = 81
e) E[Y2] = Var[Y] + ?
E[Y]2 = 13
f) E[(Y-1)(Y+1)] = E[Y2 – 1] = E[Y
? 2] – 1 = 12
Bro Exam Tip: This has come
up in exams multiple times.
S2 Preview
If X is the throw of a fair die, this obviously is its distribution...
𝒙
1
2
3
4
5
6
𝑷 𝑿=𝒙
1
6
1
6
1
6
1
6
1
6
1
6
We call this a discrete?uniform distribution.
If had say an 𝑛-sided fair die, then:
𝑛+1
𝐸(𝑋) = ?
2
𝑛2 − 1
?
π‘‰π‘Žπ‘Ÿ(𝑋) =
12
You won’t have exam questions on these, but you’ll revisit them in S2.
Example
Digits are selected at random from a table of random numbers.
a) Find the mean and standard deviation of a single digit.
b) Find the probability that a particular digit lies within one standard deviation of the
mean.
a) Our digits are 0 to 9. We have useful formulae when the numbers start from 1 rather
than 0. If the digit is R, let X = R + 1
Then E[R] = E[X – 1] = E[X] – 1 = 11/2 – 1 = 4.5
Var[R] = Var[X – 1]
= Var[X]
1
= 12 10 + 1 10 − 1
= 8.25
So 𝜎 = 2.87 (to 2sf)
?
b) We want 𝑃 4.5 − 2.87 < 𝑅 < 4.5 + 2.87
= 𝑃 1.63 < 𝑅 < 7.37
=𝑃 2≤𝑅≤7
?
6
=
10
Download