Slide set 7 Stat 330 (Spring 2015) Last update: January 16, 2015 Stat 330 (Spring 2015): slide set 7 Random Variables Intuitive idea: If the value of a numerical variable depends on the outcome of an experiment, we call the variable a random variable. Random Variable A function X : Ω 7→ R is called a random variable. Example: Very simple Dartboard Imagine we throw three darts on this board one by one and we are interested in the number of times the red area has been hit. This count is a random variable! Also note that P (red) = 1 9 on any throw. 1 Stat 330 (Spring 2015): slide set 7 More formally: Dartboard (continued...) We define X to be the function that assigns the number of times that the red area is hit in a sequence of three throws. X(ω) = k, if the outcome ω has k hits to the red area, and 3 − k hits to the gray area. X(ω) is then an integer between 0 and 3 for every possible sequence of throws of 3 darts. That is, the set of possible values for X(ω) is {0, 1, 2, 3} Notation: To avoid cumbersome notation, we write {X = x} for the event {ω|ω ∈ Ω and X(ω) = x}. 2 Stat 330 (Spring 2015): slide set 7 Practice with notation Example Suppose, 8 bits are sent through a communication channel. Each bit has a certain probability to be received incorrectly. We are interested in the number of bits that are received incorrectly. Use random variable X to “count” the number of wrong bits received. X assigns a value between 0 and 8 to each sequence in the sample space. That is, the possible values for X are {0, 1, 2, 3, 4, 5, 6, 7, 8} Examples of events and equivalent expressions using X. • No wrong bits received: {X = 0} • At least one wrong bit received: {X ≥ 1} • Exactly 2 wrong bits received: {X = 2} • Between 2 and 7 wrong bits (inclusive) received: {2 ≤ X ≤ 7} 3 Stat 330 (Spring 2015): slide set 7 Image of R.V.: all possible values X can take Definition: The image of a random variable X Im(X) := {x : x = X(ω) for some ω ∈ Ω}. is defined as 1. Put a disk drive into service, measure Y = “time till the first major failure”. Im(Y ) = (0, ∞). image of Y is an interval (uncountable image) → Y is a continuous random variable. 2. Communication channel: X = “# of incorrectly received bits” Im(X) = {0, 1, 2, 3, 4, 5, 6, 7, 8} is a finite set → X is a discrete random variable. 4 Stat 330 (Spring 2015): slide set 7 Discrete R.V.s • Assume X is a discrete random variable. The image of X is therefore countable and can be written as {x1, x2, x3, . . .} • Very often we are interested in probabilities of the form P (X = x). We can think of this expression as a function, that yields different probabilities depending on the value of x. Example: Dartboard What is the probability that you hit the red square exactly twice in 3 throws? The event “exactly 2 reds” is formally written as {ω : X(ω) = 2}, and with the simpler notation for this event is X = 2. P (2 reds) = P (X = 2) = P (RRG or RGR or GRR) = P (RRG) + P (RGR) + P (GRR) = 1 9 · 19 · 98 + 19 · 89 · 19 + 89 · 19 · 19 =? 5 Stat 330 (Spring 2015): slide set 7 Probability Mass Function Definition: Probability Mass Function, PMF The function pX (x) := P (X = x) is called the probability mass function of X. Properties of PMF: pX is the pmf of X, if and only if (i) 0 ≤ pX (x) ≤ 1 for all x ∈ {x1, x2, x3, . . .} (all values must be between 0 and 1) (ii) P i pX (xi ) = 1 (the sum of all values is 1) 6 Stat 330 (Spring 2015): slide set 7 Examples: These properties give us an easy method to check, whether a function is a probability mass function Experiment: Which of the following functions is a valid probability mass function? 1. x pX (x) -3 0.1 -1 0.45 0 0.15 5 0.25 7 0.05 2. y pY (y) -1 0.1 0 0.45 1.5 0.25 3 -0.05 4.5 0.25 3. z pZ (z) 0 0.22 5 0.17 7 0.18 1 0.18 3 0.24 7 Stat 330 (Spring 2015): slide set 7 More Examples of Discrete R.V.’s Example: Roll of a fair die Let Y be the number of spots on the upturned face of a die. Obviously, Y is a random variable with image Im(Y ) = {1, 2, 3, 4, 5, 6}. Assuming, that the die is a fair die means, that the outcomes of each face turning up are equally likely i.e., probabilities of each face turning up are equal. The probability mass function for Y therefore is 1 2 3 4 5 6 x pX (x) 16 16 16 16 16 16 8 Stat 330 (Spring 2015): slide set 7 More Examples of Discrete R.V.’s Example: Roll of a doctored die The diagram shows all six faces of a particular die. If Z denotes the number of spots on the upturned face after toss this die, what is the probability mass function for Z? Assuming, that each face of the die appears with the same probability, we have 1 possibility to get a 1 or a 4, and two possibilities for a 2 or 3 to appear, which gives a probability mass function for Z as: z p(z) 1 2 3 4 1/6 1/3 1/3 1/6 9 Stat 330 (Spring 2015): slide set 7 Statistics of R.V.s Gamblers Luck!: Toss a die. Let X 1, 3 or 5 2 or 4 X= 6 be the number of spots turned up, then if I pay you $X you pay me $2X no money changes hands. What amount of money do I expect to win? For that, we look at another function, h(x), that counts the money I win with respect to the number of spots: −x 2x h(x) = 0 for x = 1, 3, 5 for x = 2, 4 for x = 6. 10 Stat 330 (Spring 2015): slide set 7 Gambling Example Continued... In In In In In In 1/6 1/6 1/6 1/6 1/6 1/6 of of of of of of all all all all all all tosses tosses tosses tosses tosses tosses X X X X X X will will will will will will be be be be be be 1, 2, 3, 4, 5, 6, and and and and and and I I I I I I will will will will will will gain gain gain gain gain gain -1 4 -3 8 -5 0 dollars dollars dollars dollars dollars dollars In total I expect to get 1 6 · (−1) + 16 · 4 + 61 · (−3) + 16 · 8 + 16 · (−5) + 61 · 0 = 3 6 = 0.5 dollars per play. In this example, we are calculating the expected value of the function h(X) We denote this by E(h(X)) and define this mathematically in the next lecture. 11