Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 Lecture 21 Random Variables: Discrete & Continuous • A random variable is a variable whose value is determines by the outcome of a random experiment. • Random variables can be divided into two classes, discrete and continuous Discrete Random Variables • Consider tossing a coin 3 times. • There are 8 possible outcomes, each of which are equally likely. • Let X be the number of heads obtained in the experiment. • X depends on the outcome of the experiment and therefore is a random variable. • X can take one of 4 values, 0, 1, 2, 3, therefore X is a discrete random variable • A random variable is discrete if it can only take a finite number of integer values or there are infintely many values that can be labelled by an integer. 238 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 • A probability function can be defined to assign probabilities to all the distinct values that X can take, such that p ifx = x . i i f (x) = p(X = x) = (19.1) 0 otherwise. • The function f describes the distribution of the random variable X. • It is required that all probabilities sum to 1 therefore, n X f (xi ) = 1, i=1 where n may be infinite. ◦This is described as a normalisation condition and must be satisfied by any probability function. • The Cumulative Probability Function can also be useful in quantifying the probability of X taking different values. X F (xi ) = p(X ≤ xi ) = f (xi ) xi ≤x 239 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 Example 1: 240 • The cumulative proabability function F (x), may be shown to take the values: • Consider the tossing of a coin 3 times. Remember the sample space has 8 different members each of which are equally likely. 1 8 1 4 p(X ≤ 1) = F (1) = = 8 2 7 p(X ≤ 2) = F (2) = 8 8 p(X ≤ 3) = F (3) = = 1 8 p(X ≤ 0) = F (0) = • HHH, HHT, HTH, HTT, THH, THT, TTH, TTT • If X is the number of heads obtained the following are possible values for X, {x1 , x2 , x3 , x4 } = {0, 1, 2, 3}. • The probability of X taking each value may be calculated by counting the number of points in the sample space that correspond to that value. 241 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 f(i) F(i) 4/8 8/8 7/8 3/8 6/8 5/8 • I.e. 1 p(X = 0) = p1 = f (0) = 8 3 p(X = 1) = p2 = f (1) = 8 3 p(X = 2) = p3 = f (2) = 8 1 p(X = 3) = p4 = f (3) = 8 • Note that p1 + p2 + p3 + p4 = f (0) + f (1) + +f (2) + f (3) = 1 2/8 4/8 3/8 1/8 2/8 1/8 0 0 0 1 2 Number of heads 3 0 1 2 Number of heads 3 242 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 Example 2: The Binomial Distribution • A bag contains 7 red balls and 3 white balls. • 3 balls are drawn at random WITHOUT replacement. • Find the probability function for the number of red balls drawn. Solution: • The Binomial Distribution describes the processes that consist of a number of independent, identical, trials which have only two possible outcomes. • For example, success and failure, where the probability of success, p(success) = 1 − p(f ailure) and vice versa. Example: • Let R be the number of red balls drawn. • Consider a production line of children’s toys. The toys have a probability p of being faulty. • Then, p(R = 0) = f (0) = p(R = 1) = f (1) = p(R = 2) = f (2) = p(R = 3) = f (3) = 2 1 3 × × 10 9 8 3 3 × C1 × 10 3 3 × C2 × 10 7 6 5 × × 10 9 8 1 120 2 7 × = 9 8 7 6 × = 9 8 7 = 24 • A sample of n toys is taken from the line. What is the probability that exactly r are found to be faulty? = 7 40 21 40 • Consider the possible outcomes for the random experiment of drawing n toys. Each outcome is a different sequence of faulty and good toys. • The probability of a toy being good is (1 − p), therefore if r toys are faulty, n − r toys are good and the probability is pr (1 − p)n−r . • Check that 3 X i=0 f (i) = 1 • The number of ways that this selection could happen is number of ways of selecting n from r, i.e. the n r . 243 244 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 • Therefore, the probability of r faulty toys out of n is: n pr (1 − p)n−r p(r faulty out of n) = r • This defines the probability function f (r) for the random variable F , the number of faulty toys (out of n sampled). NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 Example 3: • If a single six-sided die is rolled 4 times, what is the probability that a 5 is thrown exactly 2 times? Solution: • The number of trials, n = 4 • The possible values for B are {0, 1, ....., n}. • The random variable, X= number of 5’s thrown. • Note that • The probability of throwing a 5 (success), p = 1/6 n X p(r faulty out of n) = r=0 n X • Therefore, f (r) r=0 = n X r=0 n r pr (1 − p)n−r = [p + (1 − p)]n = 1n = 1 • The distribution of F is called the binomial distribution, B(n, p), specified by the two parameters n (the number in the sample) and p (the probability of one of the two possible types). f (x) = p(X = x) =n Cr px (1 − p)n−x (1) 4! p(X = 2) = 2!(4 − 2)! 2 (4−2) 5 1 = 0.12 6 6 245 246 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 Example 4: • If two six-sided dice are rolled 3 times (a) What is the probability that a total of 12 is thrown exactly twice? (b) What is the probability that a total of 7 is thrown exactly 3 times? Solution: (a) • The number of trials, n = 3 Graphically: • Return to our toys on their production line: • Calculate the probability of n good toys in N produced. What happens to the distribution as N increases? • If p(good) = 0.5, N = 5, N = 10 and N = 50. • The random variable, X= number of 12’s thrown. • The probability of throwing a total of 12 (success), p = 1/36 • Therefore, 3! p(X = 2) = 2!(3 − 2)! 1 36 2 35 36 (3−2) = 0.002 (b) • The number of trials, n = 3 • The random variable, X= number of 7’s thrown. • The probability of throwing a total of 7 (success), p = 6/36 • Therefore, 3! p(X = 3) = 3!(3 − 3)! 3 (3−3) 5 1 = 0.005 6 6 • Example for N = 5: 5! 0.50 0.55 p(X = 0) = 0!(5 − 0)! 5! p(X = 1) = 0.51 0.54 1!(5 − 1)! 5! p(X = 2) = 0.52 0.53 2!(5 − 2)! 5! p(X = 3) = 0.53 0.52 3!(5 − 3)! 5! 0.54 0.51 p(X = 4) = 4!(5 − 4)! 5! p(X = 5) = 0.55 0.50 5!(5 − 5)! = 0.03125 = 0.15625 = 0.3125 = 0.3125 = 0.15625 = 0.03125 247 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 248 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 • Let p(good) = 0.3, N = 5, N = 10 and N = 50. • Example for N = 5: 5! p(X = 0) = 0.30 0.75 0!(5 − 0)! 5! 0.31 0.74 p(X = 1) = 1!(5 − 1)! 5! p(X = 2) = 0.32 0.73 2!(5 − 2)! 5! 0.33 0.72 p(X = 3) = 3!(5 − 3)! 5! p(X = 4) = 0.34 0.71 4!(5 − 4)! 5! 0.35 0.70 p(X = 5) = 5!(5 − 5)! = 0.16807 = 0.0.36015 = 0.0.3087 = 0.1323 = 0.02835 = 0.00243 249 NST1A Maths Course A, Lisa Jardine-Wright, Michaelmas 2006 250