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
— Presentation 10 — Stat 1050 for computer science' students — — 1-12-2012 G — 17-1-1434 H 1 RANDOM VARIABLES AND PROBABILITY DISTRIBUTIONS Definition of Random Variable A random variable is a function that associates a real number with each element in the sample space. Random variables are often designated by letters and can be classified as discrete, which are variables that have specific values, or continuous, which are variables that can have 2 any values within a continuous range. A random variable, usually written X, is a variable whose possible values are numerical outcomes of a random phenomenon. There are two types of random variables, discrete and continuous. Example Consider an experiment where a coin is tossed three times. If X represents the number of times that the coin comes up heads, then X is a discrete random variable that can only have the values 0,1,2,3 (from no heads in three successive 3 coin tosses, to all heads). No other value is possible for X. Example An example of a continuous random variable would be an experiment that involves measuring the amount of rainfall in a city over a year, or the average height of a random group of 25 people. Example Two balls are drawn in succession without replacement from an urn containing 4 red balls and 3 black balls. The possible outcomes and the values y of the random variable Y where is the number of red balls, are 4 Sample space y RR 2 RB 1 BR 1 BB 0 Y = number of red balls Possible values of the random variable is y = 0,1,2 The probability mass function is Y 0 1 2 f(y) 1/4 1/2 1/4 Discrete Sample Space 5 If a sample space contains a finite number n of different values x 1 , x 2 ,..., x n or countably infinite number of different values x 1 , x 2 ,..., x n , it is called a discrete sample space. Examples of discrete random variables are; the number of bacteria per unit area in the study of drug control on bacterial growth, the number of defective television sets in a shipment of 100. Discrete Probability Distributions: Definition: 6 The set of ordered pairs (x, f(x)) is a probability function, probability mass function or probability distribution of the discrete random variable X if for each possible outcome x, 1. f ( x) 0 2. f ( x) 1 3. P( X x) f ( x) x Example . A random variable X assumes a value equal to the sum of the rolls of two dice. Since there are 6 possible values for each die, the fundamental principle of counting asserts that there are 36 possible outcomes of the dice roll. With unbiased dice, each outcome will have a 1/36 chance of occurring. Dice Roll (x , y) x - roll of first die Number of Outcomes 7 y - roll of second die 2 3 4 5 6 7 8 9 10 11 12 (1,1) (1,2) , (2,1) (1,3) , (2,2) , (3,1) (1,4) , (2,3) , (3,2) , (4,1) (1,5) , (2,4) , (3,3) , (4,2) , (5,1) (1,6) , (2,5) , (3,4) , (4,3) , (5,2) , (6,1) (2,6) , (3,5) , (4,4) , (5,3) , (6,2) (3,6) , (4,5) , (5,4) , (6,3) (4,6) , (5,5) , (6,4) (5,6) , (6,5) (6,6) Total 36 So the probability mass function is x px(x) 2 3 4 5 6 7 8 1 / 36 2/ 36 3/ 36 4/ 36 5/ 36 6/ 36 5/ 36 1 2 3 4 5 6 5 4 3 2 1 8 9 10 11 12 4/ 36 3/ 36 2/ 36 1/ 36 Example Tossing 4 Coins one time experiment. What is the probability distribution of the discrete random variable X that counts the number of heads in four tosses of a coin? We can derive this distribution if we make two reasonable assumptions: 1. The coin is balanced, so each toss is equally likely to give a H or T. 2. The coin has no memory, so the tosses are independent. The outcome of four tosses is a sequence of heads and tails such as HTTH. There are 16 possible outcomes in all. 9 1 P(X = 0) = 16 = 0.0625 4 P(X = 1) = 16 = 0.25 And so on Now if we want the probability of at least two heads, then we want P(X 2) = P(X = 2) + P(X = 3) + P(X = 4) = 6 4 1 = 0.6875 16 16 16 10 And if we want the probability of at least one head we have two choices 1. We can compute the probability as above: P(X 1) = P(X = 1) + P(X = 2) + P(X = 3) + P(X = 4) = 164 + 166 164 161 = 0.9375 2. Or, the easier way is to use the compliment rule P(X 1) = 1 – P(X< 1) = 1 – P( X = 0) = 1 = 1 – 0.0625 = 0.9375 Exercise Show that the following function f ( x) x 1 , x 2,1,2,3 is aprobability 4 mass function? Find p(X>1),p(0<X<2.5) , p(X<2) 11 1 16 Example . (1) Find the value of c so that the following function is a probability distribution of a r.v. x: P x c x 2 , where x 0,1, 2,3 Solution P(0)+P(1)+P(2)+P(3)=1 (Note that x can only take 0, 1, 2, 3) 2c+3c+4c+5c=1, so c=1/14. (2) For this probability distribution, find P(x 2) P(x 2) =P(x=0) + P(x=1) + P(x=2) = 2c+3c + 4c = 9c = 9/14 Alternatively, P(x 2) = 1- P(x>2) = 1- P(x=3) = 15c = 1- 5/14=9/14. 12 Mean and Variance of a discrete r.v x The mean xP x x (The mean of a r.v. is also called as the expected value.) The variances x2 x x P x x 2 P x x2 2 x x Var( X ) E ( X ) ( E ( X )) 2 2 The standard deviation = x 13 2 Example Toss a coin twice, x = # of heads. Find The probability distribution is 0 x P(x) 0.25 1 0.5 x and . 2 x 2 0.25 x xP x 0 0.25 1 0.5 2 0.25 1 x (the number of heads we can expect to get if we toss a coin twice). x2 x 2 P x x2 02 0.25 12 0.5 22 0.25 12 1.5 1 0.5 x . Example A contractor is required by a county planning department to submit from 1 to 5 different forms, depending on the nature of the project. 14 Let x = # of forms required of the next contractor, and px kx for x=1,2,3,4,5. (a) What is the value of k? From the form of P(x), we have P(1) P(2) P(3) P(4) P(5) 1 (Note x can only take 1, 2, 3, 4, 5) That is, 1k + 2k + 3k + 4k + 5k = 1. So k = 1/15 (since P(x) = x/15 are between 0 and 1 for x = 1, 2, 3, 4, 5 and they sum to 1, k=1/15 is a valid solution. (b) What is the probability that at most 3 forms are required? P(x 3) = p(x=1) + P(x=2)+P(x=3) = 1k + 2k + 3k = 6k = 6/15 = 2/5 (c) What is the expected number (i.e., mean) of forms required ? 1P(1) + 2P(2)+3P(3)+4P(4)+5P(5) = 1k + 2*2k + 3*3k + 4*4k+ 5*5k = 55k = 55/15=3.67 x 15 (d) What is the SD of the number of forms required? x2 x2 P( x) x2 13 k 23 k 33 k 43 k 53 k 3.672 225k 3.672 225/15 3.672 1.53 x x2 1.53 1.24 &&& End of Presentation &&& 16