chapter 4: continuous random variablesfaculty.nps.edu/rdfricke/oa3101/chapter 4.pdf · chapter 4:...

126
Chapter 4: Continuous Random Variables Professor Ron Fricker Naval Postgraduate School Monterey, California 5/15/15 1 Reading Assignment: Sections 4.1 – 4.8, 4-10 & 4.12

Upload: duongkiet

Post on 27-Jun-2018

243 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Chapter 4:Continuous Random Variables

Professor Ron FrickerNaval Postgraduate School

Monterey, California

5/15/15 1Reading Assignment: Sections 4.1 – 4.8, 4-10 & 4.12

Page 2: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Goals for this Chapter

•  Learn about continuous random variables–  Probability distributions–  Expected value–  Also, variance and standard deviation

•  Define specific distributions–  Uniform–  Normal–  Gamma (and chi-square, exponential)–  Beta

•  Define and apply Tchebycheff’s Theorem

5/15/15 2

Page 3: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Sections 4.1 and 4.2:Continuous Random Variables

•  Continuous random variables can take on any value within a range or ranges–  Continuous random variables have an

uncountably infinite number of values they can take on

•  E.g., with a perfectly precise measuring instrument, missile velocity is continuous

–  Compared to discrete data that can take on either a finite or countably infinite number of values

•  E.g., the number of missiles fired is discrete – you can’t fire half of a missile

5/15/15 3

Page 4: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Continuous Random Variables

•  An important mathematical distinction with continuous random variables is that

–  That is, for a continuous r.v. the probability that any particular value y occurs is always zero

•  This requires both a change in how we think about continuous r.v.s and a change in notation–  But, while the differences are important, the

intuition that we’ve developed about random variables will carry over

5/15/15 4

P (Y = y) = 0, 8y

Page 5: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Some Definitions

•  Definition 4.1: Let Y denote any r. v. The (cumulative) distribution function (cdf) of Y, denoted by F(y), is such that for

•  Note that this is the same definition we used for discrete random variables at the start of Chapter 3 (just not mentioned in the text)–  But some of the CDF’s characteristics differ

between discrete and continuous r.v.s–  Let’s illustrate with some examples…

5/15/15 5

F (y) = P (Y y)�1 < y < 1

Page 6: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.1

•  Suppose that Y has a binomial distribution with n = 2 and p = 1/2. Find F(y).

•  Solution:

5/15/15 6

Page 7: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

A Graph of the CDF

5/15/15 7

Page 8: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.1 Continued

•  What is F(-2)? And F(1.5)?•  Solution:

5/15/15 8

Page 9: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

CDFs for Discrete Random Variables

•  CDFs for discrete random variables are step functions–  They jump at each y value at which there is

positive probability –  Otherwise, in between them the function is flat

•  This occurs because the CDF only increases at the finite or countable number of points with positive probability

•  Also, the function is always a monotonic, nondecreasing function

5/15/15 9

Page 10: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Properties of a Distribution Function

•  Theorem 4.1: If F(y) is a (cumulative) distribution function, then1. 

2.  3.  F(y) is a (right continuous) nondecreasing

function of y. •  Nondecreasing means that if y1 and y2 are any

values such that y1 < y2, then

5/15/15 10

F (1) = limy!1

P (Y y) ⌘ limy!1

F (y) = 1.

F (�1) = limy!�1

P (Y y) ⌘ limy!�1

F (y) = 0.

F (y1) F (y2)

Page 11: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Distribution Functions for Continuous R.V.s

•  Definition 4.2: A r.v. Y with distribution function F(y) is said to be continuous if F(y) is continuous for *

•  What this means is that the distribution function for continuous random variables is a smooth function

•  Example:

5/15/15 11

�1 < y < 1

* Technically, the first derivative of F(y) must also exist and be continuous except for, at most, a finite number of points in any finite interval

Page 12: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Probability Density Functions

•  Definition 4.3: Let F(y) be the distribution function for a continuous random variable Y. Then f (y), given by

wherever the derivative exists, is called the probability density function (pdf) for the random variable Y

•  It’s the analog of the probability mass function for discrete random variables

5/15/15 12

f(y) =dF (y)

dy= F 0(y)

Page 13: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

A Note on the Notation

•  The notation f (y) is shorthand notation for the pdf of random variable Y evaluated at y –  Whenever it does not cause confusion, the

convention is that the small Roman letter inside the parentheses denotes the r.v. of interest

–  If we want to be explicit, we can write fY(y) •  With one r.v. it is usually clear without the

subscript, but with two or more it can be confusing / unclear–  I.e., Let r.v. Y have pdf fY(.) and r.v. X have pdf fX(.) –  Also, sometimes different letters used to distinguish:

Let r.v. Y have pdf f (.) and r.v. X have pdf g(.) 5/15/15 13

Page 14: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

The Connection Between PDFs and CDFs

•  It follows from Definitions 4.2 and 4.3 that

where is the pdf and t is the variable of integration

•  In a picture:

5/15/15 14

F (y) =

Z y

�1f(t)dt,

f(·)

F (y0)

Page 15: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

PDFs Are Theoretical Models of Reality

•  The idea visually: Increasing the sample size from 500 to 50,000 to 5 million to infinity

5/15/15 15

y

f(y)

-3 -2 -1 0 1 2 3

0.0

0.1

0.2

0.3

0.4

y

f(y)

-3 -2 -1 0 1 2 3

0.0

0.1

0.2

0.3

0.4

y

f(y)

-3 -2 -1 0 1 2 3

0.0

0.1

0.2

0.3

0.4

-3 -2 -1 0 1 2 3

0.0

0.1

0.2

0.3

0.4

y

f(y)

As the sample size increases, the “density histogram” gets smoother and smoother. In the limit, it’s a smooth curve that characterizes a continuous random variable.

Page 16: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Properties of Density Functions

•  Theorem 4.2: If f(y) is a (probability) density function for a continuous random variable, then1. 

2. 

•  That is, pdfs are always non-negative and they must integrate to 1–  Functions that do not have these properties

cannot be density functions

5/15/15 16

f(y) � 0 for all y,�1 < y < 1Z 1

y=�1f(y)dy = 1

Page 17: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.2

•  Suppose that

•  That is, graphically the cdf is

•  Find the pdf for Y and graph it.

5/15/15 17

F (y) =

8<

:

0, for y < 0

y, for 0 y 1

1, for y > 1

Page 18: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.2 Solution

5/15/15 18

Page 19: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Solution from the Text

•  Note that f(y) meets the pdf requirements: and

5/15/15 19

f(y) � 0 for all y,�1 < y < 1Z 1

y=�1f(y)dy = 1

Page 20: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.3

•  Let Y be a continuous r.v. with pdf

Find F(y). Graph both f (y) and F(y).•  Solution

5/15/15 20

f(y) =

⇢3y2, for 0 y 1

0, otherwise

Page 21: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.3 Solution (cont’d)

5/15/15 21

Page 22: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Solution from the Text

5/15/15 22

Page 23: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Quantiles and Percentiles

•  Definition 4.4: For 0 < p < 1, –  If Y is continuous, the pth quantile of Y, denoted ,

is the value such that–  If Y is discrete, the pth quantile of Y, , is the

smallest value such that–  is the 100pth percentile of Y

•  Example: In 2012, an SAT score of 700 is the 95th percentile for males (0.95 quantile) and the 96th percentile (0.96 quantile) for females–  Note how quantiles are on a 0-1 scale while

percentiles are on a 1-100 (percent) scale

5/15/15 23

�p

P (Y �p) = F (�p) � p

P (Y �p) = F (�p) = p�p

100⇥ �p

Page 24: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Important Quantiles (and Percentiles)

•  Note that is the median quantile–  The median is the value such that the probability

of being less than it (and greater than it) is 0.5:

–  Example: In helmet testing, one of the quantities of interest is “V50” – the velocity at which there is a 50% probability that the helmet is perforated

•  That’s the median perforation velocity•  Other special percentiles:

–  Minimum: 0th percentile (or 0 quantile)–  Maximum: 100th percentile (or 1.0 quantile)

5/15/15 24

�0.5

P (Y �0.5) = 0.5

Page 25: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Calculating Probabilities for Continuous R.V.s

•  Theorem 4.3: If a random variable Y has density function f (y) and a < b, then the probability that Y falls in the interval [a, b] is

•  Graphically:

5/15/15 25

P (a Y b) =

Z b

y=af(y)dy

Page 26: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

A Couple of Notes

•  Remember that if Y is continuous, then

•  Thus, it follows:–  That is, whether the endpoints are included in the

integration or not does not matter for continuous random variables

–  This is not true for discrete random variables •  You will demonstrate this when you do

homework problem 4.7

5/15/15 26

P (a Y b) = P (a < Y < b)

P (Y = a) = P (Y = b) = 0

Page 27: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.4

•  Given and elsewhere, find c so that f (y) is a valid pdf

•  Solution:

5/15/15 27

f(y) = cy2, 0 y 2 f(y) = 0

Page 28: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.5

•  For Example 4.4, find and also

•  Solution:

5/15/15 28

P (1 Y 2)P (1 < Y < 2)

Page 29: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.2 Homework

•  Do problems 4.1, 4.2, 4.3, 4.7, 4.16, 4.19

5/15/15 29

Page 30: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.3:Expected Value, Variance, & Std. Deviation

•  The expected value and variance of a continuous r.v. are intuitively the same as discrete r.v.s–  Expected value is the value you would get if you

drew an infinite number of observations from the distribution and averaged them

–  Variance (and standard deviation) measure how spread out the distribution is (and thus how variable the data will be that come from the distribution)

•  Where the definitions differ is in the mathematical details

5/15/15 30

Page 31: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Defining Expected Value

•  Definition 4.5: Let Y be a continuous random variable; then the expected value of Y isprovided the integral exists

•  Definition 4.6: Let g(y) be a function of Y; then the expected value of g(y) isprovided the integral exists

5/15/15 31

E[g(Y )] =

Z 1

y=�1g(y)f(y)dy

E(Y ) =

Z 1

y=�1yf(y)dy

Page 32: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example

•  The density function for the time to failure of an AN/ZPY-4 UAV radar system that has operated successfully for 600 or more hours is for , and 0 otherwise–  Find the expected time to failure for radar systems

that successfully operate for 600 or more hours•  Solution:

5/15/15 32

0 y 1f(y) = 400y

Page 33: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Expected Value Theorems

•  The expected value theorems we proved for discrete r.v.s carry over to continuous r.v.s

•  Theorem 4.5: Let c be a constant and let g(y), g1(y), g2(y),…, gk(y) be functions of a continuous r.v. Y. Then the following results hold:1.  2.  3. 

5/15/15 33

E(c) = c

E[cg(Y )] = cE[g(Y )]

E[g1(Y ) + g2(Y ) + · · ·+ gk(Y )] = E[g1(Y )]

+ E[g2(Y )]

+ · · ·+ E[gk(Y )]

Page 34: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Defining Variance and Standard Deviation

•  The definitions are precisely the same as with discrete random variables, the only difference is in how they’re calculated

•  Definition 3.5: For a r.v. Y with , the variance of Y, V(Y), is defined as

•  But since Y is continuous, the calculation is

5/15/15 34

E(Y ) ⌘ µ

V (Y ) = E[(Y � µ)2].

�2 =

Z 1

�1(y � µ)2f(y)dy

Page 35: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

And Remember...

•  Theorem 3.6: Let Y be a discrete r.v. with probability function p(y) and mean . Then

•  So now we just calculate the variance as

•  And, as before, the standard deviation of Y is the positive square root of V(Y):

5/15/15 35

µ

V (Y ) ⌘ �2 = E[(Y � µ)2] = E(Y 2)� µ2.

� =p�2

�2 = E(Y 2)� [E(Y )]2

=

Z 1

�1y2f(y)dy �

✓Z 1

�1yf(y)dy

◆2

Page 36: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.6

•  From Example 4.4 we have the density function for and zero elsewhere. Find and

•  Solution:

5/15/15 36

f(y) = (3/8)y2 0 y 2µ = E(Y ) �2 = V (Y )

Page 37: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.6 Solution (cont’d)

5/15/15 37

Page 38: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.3 Homework

•  Do problems 4.20, 4.21, 4.25, 4.26–  Note: For Problem 4.26, prove the results directly

from Theorem 4.4•  You already proved them using the equivalent

of Theorem 4.5 in Chapter 3…

5/15/15 38

Page 39: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.4:The Uniform Distribution

•  A uniform distribution arises when the probability of an event occurring in some fixed interval is the same over all possible intervals of that size–  The text uses an example of bus arrival, where the

bus is just as likely to arrive in any two-minute interval over a 10-minute window:

5/15/15 39

Page 40: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Defining the Uniform Distribution

•  Definition 4.6: If , a random variable Y has a uniform distribution on the interval often denoted , iif the density of Y is

•  In a picture:

5/15/15 40

✓1 < ✓2

f(y) =

⇢ 1✓2�✓1

, ✓1 y ✓20, otherwise

f(y)

y✓1 ✓2

1

✓2 � ✓1

(✓1, ✓2),U(✓1, ✓2)

Page 41: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Parameters of Distributions

•  Definition 4.7: The constants that determine the specific form of a density function are called parameters–  For the uniform dist’n, the parameters are and

•  The parameters define a specific uniform dist’n–  In the bus example, we had and

5/15/15 41

✓1

✓1 = 0 ✓2 = 10

✓2

✓2✓1

1

✓2 � ✓1=

1

10

Page 42: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Why the Uniform Distribution?

•  In experiments and surveys where you might need to select a random sample, easiest way is to assign each entity a computer-generated uniformly distributed random number

•  Some continuous random variables in physical, biological, and other sciences have a uniform distribution–  E.g., if the number of arrivals into some system has

a Poisson distribution and we’re told that exactly one event happened in the interval (0, t) then the time of occurrence of the event is uniformly distributed on (0, t)

5/15/15 42

Page 43: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.7

•  Arrivals at a repair depot follow a Poisson distribution. It is known that in one 30-minute period one customer arrived. Find the probability that the customer arrived during the last 5 minutes of the 30-minute period.

•  Solution:

5/15/15 43

Page 44: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Why the Uniform Distribution, Part Deux

•  The uniform distribution also useful for simple models where you have little information about the phenomenon of interest

•  Theoretically, they’re useful for generating other types of random variables–  That is, it’s usually easy to generate uniform

random variables on a computer–  Then, if what you want is a random variable Y with

distribution F(y), it’s often possible to transform a uniform random variable to achieve the desired distribution

•  Details beyond this class, but know it’s possible5/15/15 44

Page 45: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Expected Value and Variance of

•  Theorem 4.6: For with ,

and•  Proof:

5/15/15 45

U(✓1, ✓2)

Y ⇠ U(✓1, ✓2) ✓1 < ✓2

E(Y ) =✓1 + ✓2

2V (Y ) =

(✓2 � ✓1)2

12

Page 46: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Proof Continued

5/15/15 46

Page 47: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Interactive Uniform Distribution Demo

5/15/15 47

From R (with the shiny package installed), run: shiny::runGitHub('ContDistnDemos','rdfricker')

Page 48: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example

•  In a warfare simulation, it is assumed that the length of time of a particular engagement type is uniformly distributed on the interval (30, 480) minutes–  Find the expected value and standard deviation of

the engagement time–  What is the probability that a random engagement

will be longer than six hours?•  Solution:

5/15/15 48

Page 49: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example Solution Continued

5/15/15 49

Page 50: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Check the Solution in R

•  The R functions for the uniform distribution are dunif() and punif() –  f (y0): dunif(y0, , ) –  F(y0): punif(y0, , )

•  So, back to the example:

•  And, from first principles:

•  Also note that to generate n uniform random variables: runif(n, , )

5/15/15 50

✓1 ✓2✓1 ✓2

✓1 ✓2

Page 51: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Using R to Find Quantiles (of a Uniform R.V.)

•  The R syntax is qunif(p, , ) •  It finds the value such that•  In a picture:

•  Examples:

5/15/15 51

✓1 ✓2

P (Y �p) = p�p

f(y)

y✓1 ✓2

1

✓2 � ✓1

p

�p

Page 52: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.4 Homework

•  Do problems 4.48, 4.53, 4.54, 4.55•  Notes:

–  Confirm the results of all your calculations in R and include the appropriate R output in your submission

5/15/15 52

Page 53: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.5:The Normal Distribution

•  The normal distribution is widely used for a variety of reasons–  Many natural phenomenon are normally

distributed–  Statistical theory (the Central Limit Theorem,

which you’ll learn about in OA3102) says that the sums and means of random variables with other distributions will be approximately normally distributed

•  It’s the famous “bell-shaped” distribution–  The empirical rule we’ve been using is derived

from it5/15/15 53

Page 54: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Defining the Normal Distribution

•  Definition 4.8: A random variable Y is said to have a normal distribution iff, for and , the density of Y is

•  The parameters for the normal are and

•  Typically denoted 5/15/15 54

�2 > 0�1 < µ < 1

f(y) =1

�p2⇡

e�(y�µ)2/2�2

⌘ 1

�p2⇡

exp

✓�(y � µ)2

2�2

◆,�1 < y < 1

µ �

N(µ,�2)

Page 55: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

55

Two Normal Distributions

5/15/15

Page 56: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

The Empirical Rule

•  For the normal distribution:

•  In many situations, it is a useful rule of thumb56

0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40

-4 -3 -2 -1 0 1 2 3 4 Standard deviations from the mean

99.7%

–  99.7% is within 3 standard deviations

68%

–  68% of the probability is within 1 standard deviation of the mean

95%

–  95% is within 2 standard deviations

5/15/15

Page 57: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Expected Value and Variance of the Normal Distribution

•  Theorem 4.7: If Y is normally distributed, then and–  We will not prove this – see Section 4.9 in the text

if you’re interested•  Note how in all the other distributions we only

use as shorthand for E(Y) and as shorthand for V(Y)

•  But for the normal distribution they are not shorthand – they are the actual results in terms of the normal distribution’s parameters

5/15/15 57

E(Y ) = µ V (Y ) = �2

µ �2

Page 58: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Interactive Normal Distribution Demo

5/15/15 58

From R (with the shiny package installed), run: shiny::runGitHub('ContDistnDemos','rdfricker')

Page 59: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Illustrating Probabilities from a Normal Distribution

•  As with all continuous distributions, probabilities are the area under the pdf.

•  To illustrate for the normal:

5/15/15 59

From R (with the shiny package installed), run: shiny::runGitHub('NormalProbDemos','rdfricker')

Page 60: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

60

Some Notation

•  We use Z to represent a random variable from a standard normal distribution: N(0,1)

•  If Z has a standard normal distribution, the cdf, , is often denoted by

•  Because the normal is symmetric, for Z and

•  Also note that–  – 

�(0) = 0.5

�(z)F (z) = P (Z z)

�(z) = 1� �(�z)

P (Z > z) = 1� P (Z z) = 1� �(z)P (a < Z < b) = �(b)� �(a)

5/15/15

Page 61: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Standardizing a Normally Distributed R.V.

•  Standardizing means transforming an observation from a into a N(0,1) observation–  If Y comes from a then

has a N(0,1) distribution•  Using the new notation:

61

N(µ,�2)

N(µ,�2) Z = (Y � µ)/�

P (a Y b) = P

✓a� µ

� Z b� µ

= �

✓b� µ

◆� �

✓a� µ

5/15/15

Page 62: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

62

Standardizing:

•  Example: Start with Y~N(20,25)

•  Subtract the mean–  i.e., shift the location

•  Divide by the standard deviation–  i.e., rescale

205

0 5 10 15 20 25 30 35 40

-20 -15 -10 -5 0 5 10 15 20

-4 -3 -2 -1 0 1 2 3 4

05

01

µ =� =

µ =

µ =

� =

� =

Z = (Y � µ)/�

5/15/15

Page 63: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Calculating Normal Probabilities

•  The normal pdf is not directly integrable–  Must use numerical integration–  Not practical to do routinely, so values are tabulated

•  Then, just look up the probabilities either in a table (Table 4 of Appendix 3) or via R

•  Table is for standard normal–  So, either standardize then look up or think about the

problem in terms of standard deviations from the mean:

5/15/15 63

Page 64: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Table 4

5/15/15 64

Page 65: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.8

•  Let Z denote a standard normal r.v. Find:1.  2.  3. 

•  Solutions:

5/15/15 65

P (Z > 2)

P (�2 Z 2)

P (0 Z 1.73)

Page 66: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.8 Solution Continued

5/15/15 66

Page 67: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Check the Solutions in R

•  The R functions for the normal distribution are dnorm() and pnorm() –  f (y0): dnorm(y0, , ) –  F(y0): pnorm(y0, , )

•  So, back to the example:

•  Also note that to generate n normally distributed random variables: rnorm(n, , )

5/15/15 67

µ

µ

�µ

#3#2#1

Page 68: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Using R to Find Quantiles (of a Normal R.V.)

5/15/15 68

P (Y �p) = p�p

�p

p

•  The R syntax is qnorm(p, , ) •  Just like with the uniform distribution, it finds

the value such that•  In a picture:

•  Examples:

µ �

Page 69: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Interactive Quantile Demo

5/15/15 69

From R (with the shiny package installed), run: shiny::runGitHub('QuantileDemos','rdfricker')

Page 70: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Determining Quantiles from the Table

•  To use the table, first determine the correct probability, then read to the margins

•  E.g., Find the quantile corresponding to p = 0.975 –  In this case, in the table,

use “Area”=1-0.975=0.025 –  The quantile, then, is

= 1.96

5/15/15 70

�0.975

Page 71: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.9

•  The ASVAB scores for Marines joining the Marine Corps are normally distributed with mean 75 and standard deviation 10. What fraction of the scores are between 80 and 90?

•  Solution:

5/15/15 71

Page 72: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.9 Solution Continued

•  Now, what is the 90th percentile of this distribution?

5/15/15 72

Page 73: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Original Scale Vs. Transformed Scale

5/15/15 73

Page 74: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example: Range Probable Error

•  The U.S. Army defines range probable error (RPE) as the distance beyond the aim point that you are equally likely to be within or beyond

•  So, assuming impact location has a normal distribution, show that one range probable error equals 0.675 standard deviations

745/15/15

Page 75: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example Solution

•  Solution:

5/15/15 75

Page 76: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example:Estimating Possibility of Casualties

•  The South African G6 155mm Howitzer has:–  a RPE of 144 meters at a range of 30 km,–  a round bursting radius of 50 meters, and–  guidance prohibits aiming a round closer than

300 meters from friendly troops•  What is the chance of injuring a friendly troop

when the aim point: (1) is 30 km from the gun and (2) it is as close to friendly troops as guidance allows?

765/15/15

Page 77: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example Solution

•  Solution:

5/15/15 77

Page 78: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.4 Homework

•  Do problems 4.58, 4.61, 4.63, 4.64, 4.68, 4.69, 4.71, 4.74

•  Notes:–  Use R instead of the Applet

•  Confirm all of your Table 4 results in R •  In 4.58 and 4.64, ignore the questions about

the two axes in the Applet5/15/15 78

Page 79: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.6:The Gamma Distribution

•  Note that, in addition to the normal distribution being symmetric about its mean, negative observations are (always) possible

•  But lots of real-world phenomenon can only be positive and come from skewed distributions

•  Examples:–  Time between failures–  Distance to shell impact–  Time to receipt of repair

part5/15/15 79

Example of a right-skewed distribution

Page 80: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Defining the Gamma Distribution

•  Definition 4.9: A random variable Y has a gamma distribution with parameters and iff the density of Y iswhere

•  is the gamma function:ü  ü  for anyü  for integer n

5/15/15 80

↵ > 0� > 0

�(↵) =

Z 1

0y↵�1e�ydy

�(↵)�(1) = 1

�(↵) = (↵� 1)�(↵� 1)

�(n) = (n� 1)!

↵ > 1

f(y) =

(y↵�1e�y/�

�↵�(↵) 0 y < 10, elsewhere

Page 81: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Gamma Distribution Examples

•  Often is called the shape parameter and is called the scale parameter

5/15/15 81

↵ �

Page 82: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Interactive Gamma Distribution Demo

5/15/15 82

From R (with the shiny package installed), run: shiny::runGitHub('ContDistnDemos','rdfricker')

Page 83: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Gamma Distribution Calculations (in R)

•  As with the normal, the gamma pdf is not directly integrable – use R for the calculations

•  The R functions for the gamma distribution: –  f (y0): dgamma(y0, , )

–  F(y0): pgamma(y0, , )

•  The pth quantile, : –  qgamma(p, , )à note the typo in the book (p. 186)

•  Generating n random observations from gamma distributions: rgamma(n, , )

•  Can also use the syntax: pgamma(y0,shape= ,scale= )

5/15/15 83

1/�

1/�

P (Y �p) = p↵ 1/�

↵ 1/�

↵ �

Page 84: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

The R Help Page

5/15/15 84

Page 85: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Expected Value and Variance of the Gamma Distribution

•  Theorem 4.8: If Y has a gamma distribution, then and

•  Proof:

5/15/15 85

E(Y ) = ↵� V (Y ) = ↵�2

Page 86: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Theorem 4.8 Proof Continued

5/15/15 86

Page 87: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Theorem 4.8 Proof Continued

5/15/15 87

Page 88: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example

•  The time between failures (in thousands of hours) of a Seasparrow missile launcher can be well modeled by a gamma distribution with and .

•  What is the probability the launcher will be operational for more than 2,000 hours?–  Solution:

•  What is the median number of hours until launcher failure?–  Solution: or 1,678 hours

5/15/15 88

↵ = 2 � = 1

Page 89: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Defining the Chi-Square Distribution

•  Definition 4.10: A random variable Y has a chi-square distribution with degrees of freedom iff Y is a gamma-distributed r.v. with parameters and –  is the Greek letter “nu”–  The term “degrees of freedom” will become clear

in OA3102•  Theorem 4.9: If Y has a chi-square ( )

distribution with degrees of freedom, then and

5/15/15 89

↵ = ⌫/2 � = 2

�2

⌫E(Y ) = ⌫ V (Y ) = 2⌫

Page 90: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Interactive Chi-square Distribution Demo

5/15/15 90

From R (with the shiny package installed), run: shiny::runGitHub('ContDistnDemos','rdfricker')

Page 91: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Table 6 of Appendix 3

5/15/15 91

Page 92: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Chi-square Distribution Calculations (in R)

•  The R functions for the chi-square distribution: –  f (y0): dchisq(y0, ) –  F(y0): pchisq(y0, )

•  The pth quantile, : –  qchisq(p, )

•  Generating n random observations from chi-square distributions: rchisq(n, )

5/15/15 92

P (Y �p) = p

Page 93: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

The R Help Page

5/15/15 93

Page 94: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Defining the Exponential Distribution

•  Definition 4.11: A random variable Y has an exponential distribution with parameter iff the density of Y is

–  This is a gamma distribution with parameter •  Theorem 4.10: If Y has an exponential

distribution, then and–  If is measured as the average number of time

units per event then is the rate of events: the expected number of events per time period

5/15/15 94

� > 0

f(y) =

⇢ 1� e

�y/� , 0 y < 10, elsewhere

↵ = 1

E(Y ) = � V (Y ) = �2

�1/�

Page 95: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Interactive Exponential Distribution Demo

5/15/15 95

From R (with the shiny package installed), run: shiny::runGitHub('ContDistnDemos','rdfricker')

Page 96: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Exponential R.V.s are “Memoryless”

•  Exponential dist’ns have the memoryless property: If Y has an exponential distribution, with parameter , then

•  Proof:

5/15/15 96

P (Y > a+ b|Y > a) = P (Y > b)� > 0

Page 97: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Proof of the Memoryless Property (cont’d)

5/15/15 97

Page 98: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Exponential Distribution Calculations (in R)

•  The R functions for the exponential distribution: –  f (y0): dexp(y0, ) –  F(y0): pexp(y0, )

•  The pth quantile, : –  qexp(p, )

•  Generating n random observations from exponential distributions: rexp(n, )

5/15/15 98

P (Y �p) = p

1/�

1/�

1/�

1/�

Page 99: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

The R Help Page

5/15/15 99

Page 100: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example

•  On average there are 2 hits per minute on the Navy.com recruiting web page. If the time between hits is well modeled by the exponential distribution, what is the probability that the time between the next hit and the one that follows it:–  Is less than 2 seconds?–  Is more than 120 seconds?

•  Solution: We start by solving for the cdf,

5/15/15 100

Page 101: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Application Example Solution (cont’d)

•  Solutions in R:

5/15/15 101

Page 102: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.6 Homework

•  Do problems 4.97, 4.98, 4.104, 4.105•  Notes:

–  Use R instead of the Applet

5/15/15 102

Page 103: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.7:The Beta Distribution

•  The beta distribution is a two-parameter ( ) distribution defined on the interval

•  Often used to model proportions–  E.g., the proportion of time it takes to repair a

machine•  Figure 4.17

hints that it’s a very flexible distributional family

5/15/15 103

↵,�0 y 1

Page 104: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Defining the Beta Distribution

•  Definition 4.12: A random variable Y has a beta distribution with parameters and iff the density of Y iswhere

ü Don’t worry about the material in the text on the incomplete beta function

5/15/15 104

↵ > 0� > 0

f(y) =

(y↵�1(1�y)��1

B(↵,�) 0 y 1

0, elsewhere

B(↵,�) =

Z 1

0y↵�1(1� y)��1dy =

�(↵)�(�)

�(↵+ �)

Page 105: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Interactive Beta Distribution Demo

5/15/15 105

From R (with the shiny package installed), run: shiny::runGitHub('ContDistnDemos','rdfricker')

Page 106: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Expected Value and Variance of the Beta Distribution

•  Theorem 4.11: If Y has a beta dist’n, then

and

•  Proof:

5/15/15 106

E(Y ) =↵

(↵+ �)V (Y ) =

↵�

(↵+ �)2(↵+ � + 1)

Page 107: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Theorem 4.11 Proof Continued

5/15/15 107

Page 108: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Beta Distribution Calculations (in R)

•  The R functions for the beta distribution: –  f (y0): dbeta(y0, , ) –  F(y0): pbeta(y0, , ) à note the book typo (p. 195)

•  The pth quantile, : –  qbeta(p, , ) à note the typo in the book (p. 195)

•  Generating n random observations from beta distributions: rbeta(n, , )

5/15/15 108

P (Y �p) = p↵

↵ �

Page 109: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

The R Help Page

5/15/15 109

Page 110: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Back to the Interactive Quantile Demo

5/15/15 110

From R (with the shiny package installed), run: shiny::runGitHub('QuantileDemos','rdfricker')

Page 111: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.11

•  Fuel tanks on a FOB are refilled every Monday. As an ORSA, you’ve determined that the fraction used each week can be modeled by a beta distribution with and . What is the probability the FOB will use up 90% or more of the fuel in a week?

•  Solution:

5/15/15 111

� = 2↵ = 4

Page 112: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.11 Solution (cont’d)

•  Check the solution in R:

5/15/15 112

Page 113: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.7 Homework

•  Do problems 4.115, 4.131•  Note:

–  For the graphs, use the R interactive application

5/15/15 113

Page 114: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.8:How to Choose the Right Distribution?

•  As we said at the start, densities for continuous r.v.s are models of the real world–  How to choose the right one?

•  Some possibilities:–  Expert judgment à subjective, non-empirical–  Theoretical considerations:

•  E.g., the CLT says that sums of independent observations will tend to a normal distribution

•  E.g., The time between events that follow a Poisson distribution are exponential

–  Empirical: Testing whether observed data “fit” a particular distribution (aka goodness-of-fit tests)

5/15/15 114

Page 115: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.10:Tchebysheff’s Theorem Redux

•  As with discrete r.v.s, Tchebysheff’s Theorem provides a conservative lower bound for the probability that an observation falls in the interval–  It applies to any probability distribution, including

continuous distributions•  Theorem 4.13: Let Y be a r.v. with finite mean

and variance . Then, for any constant k > 0,

Equivalently,

5/15/15 115

µ± k�

�2

P (|Y � µ| < k�) � 1� 1

k2.

P (|Y � µ| � k�) 1

k2.

µ

Page 116: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Proof of Tchebysheff’s Theorem

•  Proof:

5/15/15 116

Page 117: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Proof of Tchebysheff’s Theorem (cont’d)

5/15/15 117

Page 118: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.17

•  Suppose experience has shown that the length of time Y (in minutes) required to conduct periodic maintenance (PMS) on a radio follows a gamma distribution with and . A sailor takes 22.5 minutes to do PMS on the radio. Does this length of time disagree with prior experience?

•  Solution:

5/15/15 118

↵ = 3.1� = 2

Page 119: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Textbook Example 4.17 Solution (cont’d)

•  The exact solution:

5/15/15 119

Page 120: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Section 4.10 Homework

•  Do problems 4.146, 4.147, 4.148, 4.149•  Remember: The empirical rule (p. 10) says:

ü  contains approx. 68% of the probabilityü  contains approx. 95% of the probabilityü  contains almost all of the probability

5/15/15 120

µ± �

µ± 2�

µ± 3�

Page 121: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Sections 4.12:Summary

•  Continuous random variables are models of the real world–  Figuring out which distribution applies in a given

situation can be challenging•  Here and in Chapter 3, we skipped the

material on moment generating functions –  Useful for calculating the means and variances of

distributions that are hard to calculate directly•  Beyond the scope of this class, but very useful

•  We also skipped mixed distributions–  Just know that it is possible to have distributions

that are partly discrete and partly continuous5/15/15 121

Page 122: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Looking Ahead

•  Because of the Central Limit Theorem, which you’ll learn about in OA3102, the normal distribution applies in many problems

•  Besides the uniform, normal, gamma, and beta we’ve learned about here, in OA3102 you’ll also use the t, F, and (chi-square) distributions–  All are related to the normal distribution

5/15/15 122

�2

Page 123: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

This Can Get Really Complicated...

5/15/15 123

Source: Leemis, L.M., and J.T. McQuestion (2008). Univariate Distribution Relationships, The American Statistician, vol. 62, no. 1, p. 47.

Page 124: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

Memorize These Six Distributions

5/15/15 124

Page 125: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

All Are Easy to Calculate in R

•  Remember the convention: The abbreviated distribution name preceded by...–  “p” gives the cumulative probability–  “d” gives the density height (mass for discrete)–  “q” gives the pth quantile

•  Also see pt(), pf(), pchisq()5/15/15 125

Source: Wackerly, D.D., W.M. Mendenhall III, and R.L. Scheaffer (2008). Mathematical Statistics with Applications, 7th edition, Thomson Brooks/Cole.

Page 126: Chapter 4: Continuous Random Variablesfaculty.nps.edu/rdfricke/OA3101/Chapter 4.pdf · Chapter 4: Continuous Random ... Sections 4.1 – 4.8, 4-10 & 4.12 1. Goals for this Chapter

What We Have Just Learned

•  Learned about continuous random variables–  Probability distributions–  Expected value–  Also, variance and standard deviation

•  Defined specific distributions–  Uniform–  Normal–  Gamma (and chi-square, exponential)–  Beta

•  Defined and applied Tchebycheff’s Theorem

5/15/15 126