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