Chapter 6 (Non-Math)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

50

6. Random Variables

Learning Goals:

1. Understand what a random variable is and what a distribution is (6A and 6B)
2. Understand the difference between X and x (6A and 6B)
3. Understand what the expected value of a random variable is and be able to calculate the
expected value on your calculator (6C)
4. Learn to determine the expected value in an applied problem (6D)
5. Learn to write out a probability question in mathematical notation
6. Understand how to use CDF charts to determine the answer to probability questions (6E)
7. Understand the difference between the two types of questions (6E)
 Determine a probability given an axis number
 Determine an axis number given a probability of interest

6A. What is a Random Variable? From our past experience we know what a variable is. A variable is a quantity that
can vary. We usually use a letter to denote the variable (quantity). We use a letter because a number just wouldn’t
work since numbers can’t vary.
A company makes widgets and sells them for $10 each. They can make as many widgets as the want. The number
of widgets is therefore not a fixed number but a variable chosen by the company. Thus, we would want to use a
variable (say x) to represent the number of widgets made. The revenue generated by these widgets is also a
variable (say y) that is dependent on the number of widgets that we make. In algebra class we then made
equations that related the two variables ( y  10 x ). We are not interested in making equations. We are interested
in reminding ourselves what variables are and that variables take on values that we choose.
In life there are other quantities that vary (variables) and the value that the variable takes on is not chosen by us or
anybody else.
Here are some examples:
 The length of time it takes a person run to run a mile tomorrow
 The number of spots we will see after a die is rolled
 Your weight tomorrow morning
 How many baskets you will make when shooting 10 shots
 The number of customers that will come to our restaurant tomorrow for lunch
 How long it takes for an individual to get over an illness
 The number of patients admitted to the emergency room today

All of these quantities are variables since they can take on many possible values. The difference between these
variables and the number of widgets made in the example above is that the actual value of our variable is not
picked by us or anybody else. It is random. That is, the value is somewhat a matter of chance. There are any
possibilities, but we do not pick the value. So the value eventually given to these variables is random and depends
on probability.

If we wanted to do any type of decision making about the possible outcomes of a variable that varies randomly, we
would certainly want to know or estimate the probabilities of the possible outcomes of the variable. It should be
noted that the collection of probabilities is different for different situations. Suppose that a professional basketball
player sets out to shoot 10 free throws. The number of shots made is random in that we cannot predict exactly
51

how many shots will be made. There is a probability associated with each of the possibilities 0 through 10. It
should be clear that those probabilities would be very different from the probabilities of an ordinary person.

Definition: A Random Variable X is a function from the sample space of an experiment into the real numbers. That
is, a random variable assigns a numerical value to outcomes of an experiment.

A coin is tossed twice. How many heads will we get? _________________________

It is a variable because the value produced varies, that is it can take on a variety of possibilities. This variable is
random because we cannot predict in advance what the value will be.

Example: Suppose that we toss a coin two times. The Sample Space is given below. Let the random variable X
count the number of heads tossed. Thus, X assigns the number of heads tossed to each of the four outcomes as
indicated below. So if our two tosses result is HH, X assigns the number 2 to that outcome because we got 2 heads.

This is our Sample Space – the Head


Tail Tail Head
collection of all possible outcomes
of our experiment. These are not
numbers. A random variable will
Head
Tail into numbers Head
Tail
turn these outcomes
according to some rule that we
assign. In this case, the number of
Heads that we toss.

X is a variable because the value it


can take on varies (0, 1, or 2). X is random because we do not know in advance what the value will be.
Because the set of values that X can take on (0, 1, or 2) is discrete, X is a discrete random variable. Again, consider
that the experiment of tossing two coins has not yet been performed. X will count the number of heads after we
toss the coins. Since we have not yet tossed the coins the value that the variable X will be is random. That is why X
is called a random variable. Of course X cannot take on any value randomly. In this experiment X can only take on
the values 0, 1, and 2.

We now make some probability assignments. Of course the assignments cannot break the three rules for
probability assignments and we would like to make assignments that go along with our intuition and our loose
definition: Probability is a measure of how likely an event is to occur.

Question Assignment Question Assignment

P( X  0) _________ P( X  2) _________

P( X  1) _________ P( X  3) _________
52

Example: Suppose that we roll two dice. Let X be the sum of the two dice. This is also a discrete random variable. X
can only take on values 2, 3, 4, …, 12.

Example: A phone call comes into an operating station. Let the random variable X measure how long the phone
call lasts. In this case X can take on any value in an interval {the interval [0, ) } and we say that X is a continuous
random variable. Continuous random variables will be discussed later.

Other Examples:

Experiment Possible Random Var.


X Type
Values
 x
The Sum Discrete 2, 3, …, 12
Roll Two Dice
The Largest Value Discrete 1, 2, …, 6
The Number of Red Lights Discrete 0, 1, …n
Driving to School
The Time it Takes Continuous [0,  )
Number of Sessions Needed Discrete 0, 1, …
A Rehab Patient
Patient Gender Discrete 0 (male), 1 (Female)
Survival time of the patient Continuous [0,  )
A cancer patient
Helped by new medicine Discrete 0 (No), 1 (Yes)

Your turn:

Lottery Tickets

Patients on a diet

Remember the values of a random variable must be numbers. So, in some of the examples above we needed to
turn the non-number results into numerical values (0 for male and 1 for female).

Notation: We use upper case letters, X, to denote the random variable and lower case letters, x, to denote the
actual values that the random variable can become (or becomes) after the experiment is performed. X is the
concept that we are about to collect a piece of data, whereas x is after the experiment and is an actual piece of
data and now a specific number.

More on randomness:

Example: Let X be the number of lottery tickets that will be purchased this week. Discuss some things that affect
the randomness.

We are about to sell lottery tickets. X represents the number we will sell. At the end of the week we note that we
sold 2,240,173 lottery tickets. Now the randomness has ended and our data value is x  2,240,173 .
53

Example: Let X1 and X2 be the time that it takes to drive to work on two successive days. Discuss some things that
affect the randomness.

We are about to drive to work for two successive days. X1 and X2 represent the time it will take to get to work on
those two days. Suppose that it took us 31.25 minutes to get to work on day 1 and 28.5 minutes to get to work on

day 2. Now the randomness has ended and our two data values are
x1  31.25 and x2  28.5 .

Example: Let our random variable X be the survival time of a patient with a certain disease. Discuss the
randomness.

6B. The Distribution of a Random Variable: For now, we will focus on discrete random variables. A natural thing
for us to do with a random variable is to make a collection of the values that X can take on and the associated
probabilities like we did with tossing two coins. That is, make a table or function that contains the collection of
values and probabilities that tells how we distribute the total probability of 1. There are two ways to provide this
information. The first is called the probability mass function (pmf). The pmf tells us how much probability is at
each value of the random variable X. For the coin problem above the pmf is given below.

Our Notation for the pmf is f (x)  P( X  x ) Example: f (2)  P( X  2)

Note: We use the lower case f to denote the pmf. We will use of the upper case F is used for something else later.

Example: For our Toss 2 Coins Experiment, the entire pmf can be put into a table.

x 0 1 2 This table contains everything one would need to answer


f(x) .25 .50 .25 probability questions about X.

The table lists each value x from the sample space of our
We see the following from the table:

 P( X  0)  f (0)  .25 The probability that X assigns the value 0 is .25.

 P( X  1)  f (1)  .5 The probability that X assigns the value 1 is .5.

 P( X  2)  f (2)  .25 The probability that X assigns the value 2 is .25.

 P( X  any other value)  0


54

A picture of the above pmf chart can also be made. Sometimes the
picture allows us to “see” what is going on. This is especially useful
if there are many values that X can be.
This picture tells the same story about what can happen and with
what probability. This story of probability, the collection of x-
values and probabilities is called the Distribution. The picture has
the same information as the table. They both show the
distribution.

The pmf (stick figure) graph given above carries a lot of information when we have more than just a few values
that the random variable X can take on. Consider the visualization of four random variables given below. The graph
can contain much more intuitive information than we would get by looking at a table of values. While we will use
the table of values to determine answers to probability questions, the graph can give us a feeling of the
distribution.

In each of these graphs we can instantly get a


feeling for the distribution. If we looked at
random variables with many more possible x-
values, we might see even more information
that might not be seen when looking at a
table of values (see below).

The distribution is all that we need to answer


probability questions. Often the values of the
probabilities in the pmf ar3e determined
using mathematical formulas. That is the
reason that we use the functional notation
f (x) .

It is not necessary to know this, but the pmf


table for tossing two coins and counting the
number of heads can be calculated using the
formula:
2!
f ( x)  (.5)x (.5)2 x
x !(2  x)! for
x  0,1, 2
This also has the same information as the
table and picture. It is also the distribution.
55

Sometimes formulas offer a fast way to calculate discrete probabilities. With any luck, we will have tables and not
formulas. (We will be that lucky!!)

Example: Suppose that we buy a game and the game has the spinner below in it.

What is the pmf of this spinner?

x 0 1 2
f(x) .25 .50 .25

Have you ever seen this distribution (pmf) before?

Notice that this distribution is the same as tossing two coins. We can think of a random variable as some sort of
“chooser”. That is some sort of mechanical or electronic device that will generate (data) numbers according to
some master plan called the Distribution.

Example: A single die is to be rolled. Let X denote the number of spots observed. Write out the pmf of X in table
format.
x f (x)
Make a spinner that has the same distribution as X.
1 1/6

2 1/6
The purpose of such a problem is to help coordinate all of
3 1/6
our new ideas.
4 1/6
Experiment  Determine Probabilities  Write out the
pmf 5 1/6
pmf Table  Visualization  Portion of the whole 6 1/6
revisited.

6C. The Mean (Expected Value) of a Random Variable:

The Mean of a random variable X, denoted by the Greek letter  (mu), is the theoretical average of the random
variable. If we used the random variable (chooser of numbers) to randomly selected thousands and thousands of
values, we would expect the average of those data values to be close to  .
56

The Mean of a random variable, also called the Expected Value of the random variable, and may be denoted E[X].

   xf (x)
The formula for the mean is (MEMORIZE):

Example: In our coin experiment the mean number of heads in two tosses is

  0(.25)  1(.50)  2(.25)  1


Example: Roll a die. X = the number of spots seen.

1 1 1 1 1 1
  (1)  (2)  (3)  (4)  (5)  (6)  3.5
6 6 6 6 6 6

Therefore, the mean (expected) number of spots when rolling a die is 3.5. We will never get 3.5 spots, but 3.5 is
the theoretical average.

In Disneyland, where everything goes according to plan, if we rolled a die 60 times, we would get exactly 10 ones,
10, twos, 10 threes, 10 fours, 10 fives and 10 sixes. The average of our data would be:

10(1)  10(2)  10(3)  10(4)  10(5)  10(6)


x  3.5
60

Thus, the mean of a random variable is what our data mean would be in a world so perfect, that our data followed
the theoretical distribution perfectly. We don’t live in Disneyland, so it is unlikely that our data mean will equal the
equal the theoretical mean.

Example: Determine the mean of the random variable below.

x 1 2 3 4
f(x) .1 .2 .3 .4

We start by creating a row that multiplies x and f(x)

x 1 2 3 4
f(x) .1 .2 .3 .4
xf(x) .1 .4 .9 1.6

We now add the xf (x) row to get   3.0 .


57

Example (Your Turn): Determine the mean of the random variable below

x 1 2 3 4
f(x) .4 .3 .2 .1
.4 .6 .6 .4

  .4  .6  .6  .4  2.0
The Standard Deviation of a random variable (distribution) is a measure of theoretical variation of the distribution.
We will never calculate the standard deviation of a random variable. We will only need to know that it is a measure
of variation of the distribution. The larger the standard deviation is, the more variation there is in the distribution.

If we sample from a distribution with a large standard deviation, we would likely have a data set with a large value
of s (the data standard deviation). If we sample from a distribution with a small standard deviation, we would likely
have a data set with a small value of s (the data standard deviation).

The notation for the standard deviation of a discrete random variable is  (sigma) and is given by a formula that

we will never use.


  (x   )2
f ( x)

From the formula we see that if x is near the mean most of the time, then  will be small.

Often times we wish to determine the expected value of a game or business decision. The expected value (mean)
of a game is calculated the same way that the expected value of a random variable is calculated. The x-values
represent the dollars won or lost.

Example: A single die is rolled. If a 1, 2, 3, or 4 is rolled you lose $3. If a 5 or 6 is rolled then you win $5. The pmf
for the game is

x f(x)

-3 4/6 The expected value is   (3)(2 / 3)  (5)(1 / 3)  1 / 3 .

5 2/6
Thus, on average you will lose 1/3 of a dollar each time you play. You will never lose 1/3 of a dollar on any play of
the game. That is the average amount you should expect to lose each time you play. Notice that the x-values are
the dollars won (positive) and the dollars lost (negative) and not the number of spots observed on the die.

The lottery is played as follows: You pick three digits 0 through 9. If they match the numbers picked on TV, you
collect $500. If not, you lose your $1. Determine the expected value of the game. The probability that you win is .
001.

x -1 499
f(x) .999 .001
xf(x) -.999 +.499

E[X] = -.999 + .499 = -.5


6D. Applied Expected Value
58

Example: In our Batch Testing example, we concluded that if the


positivity rate is 1% and our batch sizes are 10, then the probability
that a batch comes back negative is .9044. Determine the expected Ban Batch
number of lab tests needed for a random batch of 10 patients. Note Testing!!
that without batch testing, we would always need 10 tests for 10
patients.

With batch testing, the number of tests needed is either 1 or 11. If the
batch comes back negative we are done. If the batch comes back
positive, then we would need 10 more for a total of 11.

Thus, our expected value is:

  E  X   1  (.9044)  11  (.0956)  1.956

Since we would need exactly 10 without batch testing, we are saving, on average, 8.044 lab tests per 10 patients.
This is an amazing 80% savings. Our ability to not fall behind on lab testing has greatly improved. Of course this will
change as the positivity rate changes and as the batch size changes.

If our batch size is 5, what are the possible number of lab tests needed per batch?

Example (DNA Machines): Suppose that our company performs DNA analysis for a law enforcement agency. We
currently have 2 machines that are essential to performing the analysis. When an analysis is performed, the
machine is in use for the entire day. Thus, we can perform at most two DNA analyses per day. Based on past
experience, the distribution of the random number of analyses needing to be performed on any given day are as
follows:

What does x represent here?


Jobs 0 1 2 3 4 or more
Dollars made because of the NEW
f(x) .12 .22 .31 .24 .11
machine and not the total the
x 0 0 0 900 900 company makes.

xf(x) 0 0 0 216 99

On days with three or more available jobs to perform, since we cannot perform more than two, the law
enforcement agency gives the extra jobs to our competitor. We are considering purchasing a third machine. Each
DNA analysis that the machine performs earns us a profit of $900. What is the yearly expected value of this new
machine? Assume we get jobs 365 days per year – no weekends or holidays.
How much does the new machine earn on a day with 2 or fewer analyses needed? $0

How much does the new machine earn on a day with 3 analyses needed? $900

How much does the new machine earn on a day with 4 analyses needed? $900
59

Determine the expected value of the machine per day.

  E  X   (900)  (.24)  (900)  (.11)  216  99  315


You will never make $315 on any given day. You will male $0 or $900. But, it’s as if you made $315 every day of the
year.

Determine the expected value of the machine for the entire year.

Yearly Expected Value = (Daily Expected Value)(365)  (315)  (365)  114,975

Example: Suppose that each machine takes 1/3 of a day to perform an analysis. Now each machine can perform up
to three analyses. Suppose that we currently have two machines and are considering buying another machine.

a) How many jobs need to come in before the new machine is needed?

b) How much profit will the new machine make if on a day where we get 8 jobs?

c) How much profit will the new machine make if on a day where we get 9 jobs?

d) How much profit will the new machine make if on a day where we get 10 jobs?
6E. Determining Probabilities from the Distribution Charts (CDF)

We have seen and created the pmf charts for random variables. Another and often more convenient way to
convey the distribution of a random variable is using the Cumulative Distribution Function. We define the
Cumulative Distribution Function (CDF) of a random variable to be the function that tells us how much probability
has accumulated up to and including the desired value of X. An upper case letter (F) is used for the CDF.

Definition: F ( x )  P( X  x ) The CDF tells you how much probability


has accumulated up to and including any

Example: F (5)  P( X  5) axis-value. F (5) yields the amount of

probability at X  5 and below.

This tells us the probability that the random variable X chooses a value of
x or smaller.

The CDF for the toss two coins experiment is: (Recall f (x)  P( X  x ) )

x 0 1 2 We get from the pmf to the CDF by accumulating


f(x) .25 .50 .25 (adding) probability.
F(x) .25 .75 1.00

 F (0)  P( X  0)  .25 Only the amount of probability at 0 has accumulated so far.


60

 F (1)  P( X  1)  .75 Now in addition to the probability at 0, we also have the probability at 1.

 F (2)  P( X  2)  1.00 We now have accumulated all of the possible probability.

Example: Determine the CDF of a random variable with the pmf given below.

x f(x) F(x) CDF charts will be provided for the important distributions discussed in this book. The CDF
charts are used because they are faster to use than the pmf charts. They do not require
1 .15 .15 potentially several additions. All probabilities can be calculated with at most one
2 .11 .26 subtraction. This makes them more convenient than pmf charts. They do however require a
little more intelligence to use than the pmf charts. So what!!
3 .09 .35
F(1) =
4 .35 .70
F(2) =
5 .17 .87
F(3) =
6 .13 1.0

If you don’t know what F(x) means – you will be helpless and lose points for a long time to come. So make sure you
know that F(x) means all of the probability up to and including x has already been added.

Example: Use the CDF below to answer the probability questions. For all problems with CDF charts, you must use
CDF notation before looking up the numbers in the chart. This rule stands for all future HW, quizzes and tests!

x 3 4 5 6 7 8 9
F(x) .2 .28 .50 .55 .78 .91 1

F(6)
a) P( X  6) 5 6 7
F(5)

F (6)  F (5)  .55  .50  .05

REMEMBER: F (6)  P( X  6) is NOT P( X  6) . It is the probability that has accumulated up to and including 6.

Your turn: Determine P( X  8) F (8)  F (7)  .91  .78  .13

b) P( X  5)
4 5 6
61

We are thinking of writingF (5) . Does F (5) include 5? __________ Do we want to include 5? __________

We only want the x-values less than 5. So the answer is F (4)  .28

Your turn: Determine P( X  7) F (7)  .78

What should we do first?


6 7 8

c) P(5  X ) 4 5 6

Which way did we circle? To the Right.

Which way does F(x) accumulate from? From the Left.

What is the total amount of probability? Always equals 1.

We might be tempted to write 1  F (5) . But this would remove 5 leaving us with only axis-numbers greater than 5.
The equal sign in the problem says that the probability at x = 5 is included in the answer. So,

P(5  X )  1  F (4)  1  .28  .72

What should we
7 do8first?
Your turn: P(7  X ) 6

P(7  X )  1  F (6)  1  .55  .45

Example: Determine P(4  X  8) . For this we would want to include the probability at x  4 and continue
through x  7 . We do not want to include the probability at x  8 .

So, our answer is F (7)  F (3)  .78  .2  .58

Your Turn: Determine P(5  X  8)


62

x f(x) F(x) The pmf and CDF of a random variable are given here. The pmf will not be given on
0 .0011 .0011 exams.
1 .0015 .0026
2 .0022 .0048
a) Determine P( X  9) F (9)  F (8)  .0428  .0352  .0076
3 .0027 .0075
4 .0034 .0109
5 .0047 .0156
6 .0055 .0211
7 .0069 .0280
b) Determine P( X  19) F (18)  .2703
8 .0072 .0352
9 .0076 .0428
10 .0082 .0510 What should we do first?
11 .0091 .0601
12 .0113 .0714 18 19 20
13 .0141 .0855
14 .0192 .1047
15 .0264 .1311
16 .0321 .1632
17 .0485 .2117 c) Determine P(8  X  25)
18 .0586 .2703
19 .0777 .3480
20 .0984 .4464
21 .1188 .5652 F (24)  F (7)  .7824  .0280  .7544
22 .0951 .6603
23 .0643 .7246
24 .0578 .7824
25 .0442 .8266 d) Determine P (28  X )
26 .0374 .8640
27 .0288 .8928
28 .0254 .9182
29 .0210 .9392 What should we do first?
30 .0112 .9504 27 28 29
31 .0101 .9605
32 .0091 .9696
33 .0085 .9781 P(28  X )  1  F (28)  1  .9182  .0818
34 .0072 .9853
35 .0062 .9915
36 .0053 .9968
e) Find the number k so that P(k  X )  .05
37 .0032 1.000

k = 30 k - 1What
k should
k + 1 we do first?

It is very important that you understand the difference between P( X  4) and P( X  4)


63

P( X  4) This asks for all values of X less than 4 and including 4. F (4)

P( X  4) This asks for all values of X less than 4 but not including 4. F (3)

It is very important that you understand the difference between P(6  X ) and P(6  X )

P(6  X ) This asks for all values of X greater than 6 and including 6. 1  F (5)

P(6  X ) This asks for all values of X greater than 6 not including 6. 1  F (6)

You might also like