<<

Chapter 4: Continuous Random Variables

Professor Ron Fricker Naval Postgraduate School Monterey, California

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

• Learn about continuous random variables – Probability distributions – Expected value – Also, and • Define specific distributions – Uniform – Normal – Gamma (and chi-square, exponential) – Beta • Define and apply Tchebycheff’s Theorem

5/15/15 2 Sections 4.1 and 4.2: Continuous Random Variables

• Continuous random variables can take on any value within a 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 Continuous Random Variables

• An important mathematical distinction with continuous random variables is that P (Y = y)=0, y 8 – 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 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 F (y)=P (Y y) for

5/15/15 5 Textbook Example 4.1

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

5/15/15 6 A Graph of the CDF

5/15/15 7 Textbook Example 4.1 Continued

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

5/15/15 8 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 Properties of a Distribution Function

• Theorem 4.1: If F(y) is a (cumulative) distribution function, then 1. F ( )= lim P (Y y) lim F (y)=0. y y 1 !1  ⌘ !1 2. F ( )= lim P (Y y) lim F (y)=1. y y 1 !1  ⌘ !1 3. F(y) is a (right continuous) nondecreasing function of y.

• Nondecreasing that if y1 and y2 are any values such that y < y , then F (y ) F (y ) 1 2 1  2

5/15/15 10 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

5/15/15 11

* 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 Probability Density Functions

• Definition 4.3: Let F(y) be the distribution function for a continuous Y. Then f (y), given by dF (y) f(y)= = F 0(y) dy 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 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 The Connection Between PDFs and CDFs

• It follows from Definitions 4.2 and 4.3 that y F (y)= f(t)dt, Z1 where f ( ) is the pdf and t is the variable of · integration • In a picture:

F (y0)

5/15/15 14 PDFs Are Theoretical Models of Reality

• The idea visually: Increasing the sample size from 500 to 50,000 to 5 million to infinity 0.4 0.4 0.4 0.4 0.3 0.3 0.3 0.3 f(y) f(y) 0.2 0.2 f(y) 0.2 f(y) 0.2 0.1 0.1 0.1 0.1 0.0 0.0 0.0 0.0

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

y y y y

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

5/15/15 15 Properties of Density Functions

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

1 2. f(y)dy =1 y= Z 1 • 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 Textbook Example 4.2

• Suppose that 0, for y<0 F (y)= y, for 0 y 1 8   < 1, for y>1 • That is, graphically: the cdf is

• Find the pdf for Y and graph it.

5/15/15 17 Textbook Example 4.2 Solution

5/15/15 18 Solution from the Text

• Note that f(y) meets the pdf requirements: f ( y ) 0 for all y,

5/15/15 19 Textbook Example 4.3

• Let Y be a continuous r.v. with pdf 3y2, for 0 y 1 f(y)= 0, otherwise  ⇢ Find F(y). Graph both f (y) and F(y). • Solution

5/15/15 20 Textbook Example 4.3 Solution (cont’d)

5/15/15 21 Solution from the Text

5/15/15 22 Quantiles and Percentiles

• Definition 4.4: For 0 < p < 1, – If Y is continuous, the pth quantile of Y, denoted p , is the value such that P (Y )=F ( )=p  p p – If Y is discrete, the pth quantile of Y, p , is the smallest value such that P (Y )=F ( ) p  p p – 100 is the 100pth percentile of Y ⇥ p • 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 Important Quantiles (and Percentiles)

• Note that 0 . 5 is the quantile – The median is the value such that the probability of being less than it (and greater than it) is 0.5: P (Y )=0.5  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 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 b P (a Y b)= f(y)dy   Zy=a • Graphically:

5/15/15 25 A Couple of Notes

• Remember that if Y is continuous, then P (Y = a)=P (Y = b)=0 • Thus, it follows: P (a Y b)=P (a

5/15/15 26 Textbook Example 4.4

• Given f ( y )= cy 2 , 0 y 2 and f ( y )=0   elsewhere, find c so that f (y) is a valid pdf • Solution:

5/15/15 27 Textbook Example 4.5

• For Example 4.4, find P (1 Y 2) and also   P (1

5/15/15 28 Section 4.2 Homework

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

5/15/15 29 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 Defining Expected Value

• Definition 4.5: Let Y be a continuous random variable; then the expected value of Y is 1 E(Y )= yf(y)dy y= Z 1 provided the integral exists • Definition 4.6: Let g(y) be a function of Y; then the expected value of g(y) is 1 E[g(Y )] = g(y)f(y)dy y= Z 1 provided the integral exists

5/15/15 31 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 f ( y ) = 400 y for 0 y 1 , 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 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. E (c)=c 2. E [cg(Y )] = cE[g(Y )] 3. E [g (Y )+g (Y )+ + g (Y )] = E[g (Y )] 1 2 ··· k 1 + E[g2(Y )] + + E[g (Y )] ··· k 5/15/15 33 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 E ( Y ) µ , the ⌘ variance of Y, V(Y), is defined as V (Y )=E[(Y µ)2]. • But since Y is continuous, the calculation is

1 2 = (y µ)2f(y)dy Z1

5/15/15 34 And Remember...

• Theorem 3.6: Let Y be a discrete r.v. with probability function p(y) and µ . Then V (Y ) 2 = E[(Y µ)2]=E(Y 2) µ2. ⌘ • So now we just calculate the variance as 2 = E(Y 2) [E(Y )]2 2 1 1 = y2f(y)dy yf(y)dy Z1 ✓Z1 ◆ • And, as before, the standard deviation of Y is the positive square root of V(Y): = p2

5/15/15 35 Textbook Example 4.6

• From Example 4.4 we have the density function f ( y )=(3 / 8) y 2 for 0 y 2 and   zero elsewhere. Find µ = E ( Y ) and 2 = V (Y ) • Solution:

5/15/15 36 Textbook Example 4.6 Solution (cont’d)

5/15/15 37 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 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 Defining the Uniform Distribution

• Definition 4.6: If ✓ 1 < ✓ 2 , a random variable Y has a uniform distribution on the interval ( ✓ 1 , ✓ 2), often denoted U ( ✓ 1 , ✓ 2 ) , iif the density of Y is 1 , ✓1 y ✓2 f(y)= ✓2 ✓1   0, otherwise ⇢ • In a picture: f(y)

1 ✓ ✓ 2 1

y ✓1 ✓2 5/15/15 40 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 ✓ 1 and ✓2 • The parameters define a specific uniform dist’n

– In the bus example, we had ✓ 1 =0 and ✓2 = 10

1 1 = ✓ ✓ 10 2 1

5/15/15 ✓1 ✓2 41 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 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 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 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 possible 5/15/15 44 Expected Value and Variance of U(✓1, ✓2)

• Theorem 4.6: For Y U ( ✓ 1 , ✓ 2 ) with ✓ 1 < ✓ 2 , ⇠ 2 ✓1 + ✓2 (✓ ✓ ) E ( Y )= and V (Y )= 2 1 2 12 • Proof:

5/15/15 45 Proof Continued

5/15/15 46 Interactive Uniform Distribution Demo

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

5/15/15 47 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 Application Example Solution Continued

5/15/15 49 Check the Solution in R

• The R functions for the uniform distribution are dunif() and punif()

– f (y0): dunif(y0, ✓ 1, ✓ 2)

– F(y0): punif(y0, ✓ 1 , ✓2 ) • So, back to the example:

• And, from first principles:

• Also note that to generate n uniform random

variables: runif(n,✓ 1,✓ 2)

5/15/15 50 Using R to Find Quantiles (of a Uniform R.V.)

• The R syntax is qunif(p,✓ 1,✓ 2)

• It finds the value p such that P (Y )=p  p • In a picture: f(y)

1

✓2 ✓1 p

y ✓ ✓ 1 p 2

• Examples:

5/15/15 51 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 Section 4.5: The

• 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 it

5/15/15 53 Defining the Normal Distribution

• Definition 4.8: A random variable Y is said to have a normal distribution iff, for 2 > 0 and <µ< , the density of Y is 1 1 1 (y µ)2/22 f(y)= e p2⇡ 1 (y µ)2 exp ,

5/15/15 54 Two Normal Distributions

5/15/15 55 The Empirical Rule

• For the normal distribution: – 68% of the probability 0.40 is within 1 standard 0.35

deviation of the mean 0.30 – 95% is within 2 0.25 standard deviations 0.20 – 99.7% is within 3 0.15 68% standard deviations 0.10 95% 0.05 99.7% 0.00 -4 -3 -2 -1 0 1 2 3 4 Standard deviations from the mean

• In many situations, it is a useful rule of thumb 5/15/15 56 Expected Value and Variance of the Normal Distribution • Theorem 4.7: If Y is normally distributed, then E ( Y )= µ and V (Y )=2 – 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 2 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 Interactive Normal Distribution Demo

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

5/15/15 58 Illustrating Probabilities from a Normal Distribution • As with all continuous distributions, probabilities are the area under the pdf. • To illustrate for the normal:

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

5/15/15 59 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, F ( z )= P ( Z z ) , is often denoted by (z)  • Because the normal is symmetric, for Z (0) = 0 . 5 and (z)=1 ( z) • Also note that – P (Z>z)=1 P (Z z)=1 (z)  – P (a

5/15/15 60 Standardizing a Normally Distributed R.V.

• Standardizing means transforming an observation from a N ( µ, 2 ) into a N(0,1) observation – If Y comes from a N ( µ, 2 ) then Z =( Y µ ) / has a N(0,1) distribution • Using the new notation: a µ b µ P (a Y b)=P Z     ✓ ◆ b µ a µ = ✓ ◆ ✓ ◆

5/15/15 61 Standardizing: Z =(Y µ)/

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

0 5 10 15 20 25 30 35 40

• Subtract the mean – i.e., shift the location µ = 0 = 5

-20 -15 -10 -5 0 5 10 15 20 • Divide by the standard deviation µ = 0 – i.e., rescale = 1 -4 -3 -2 -1 0 1 2 3 4 5/15/15 62 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 Table 4

5/15/15 64 Textbook Example 4.8

• Let Z denote a standard normal r.v. Find: 1. P (Z>2) 2. P ( 2 Z 2)   3. P (0 Z 1.73)   • Solutions:

5/15/15 65 Textbook Example 4.8 Solution Continued

5/15/15 66 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: #1 #2 #3

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

5/15/15 67 Using R to Find Quantiles (of a Normal R.V.)

• The R syntax is qnorm(p,µ , ) • Just like with the uniform distribution, it finds the value p such that P (Y )=p  p • In a picture:

p

p • Examples:

5/15/15 68 Interactive Quantile Demo

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

5/15/15 69 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 0 . 975 = 1.96

5/15/15 70 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 Textbook Example 4.9 Solution Continued

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

5/15/15 72 Original Scale Vs. Transformed Scale

5/15/15 73 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

5/15/15 74 Application Example Solution

• Solution:

5/15/15 75 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?

5/15/15 76 Application Example Solution

• Solution:

5/15/15 77 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 Applet 5/15/15 78 Section 4.6: The

• 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 Example of a right-skewed part distribution

5/15/15 79 Defining the Gamma Distribution

• Definition 4.9: A random variable Y has a gamma distribution with parameters ↵ > 0 and > 0 iff the density of Y is ↵ 1 y/ y e 0 y< f(y)= ↵(↵)  1 ( 0, elsewhere where 1 ↵ 1 y (↵)= y e dy Z0 • ( ↵ ) is the gamma function: ü (1) = 1 ü ( ↵ )=( ↵ 1) ( ↵ 1) for any ↵ > 1 ü ( n )=( n 1)! for integer n 5/15/15 80 Gamma Distribution Examples

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

5/15/15 81 Interactive Gamma Distribution Demo

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

5/15/15 82 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,↵ ,1 / )

– F(y0): pgamma(y0,↵ ,1 / ) • The pth quantile, P ( Y )= p :  p – qgamma(p,↵ ,1 / )à note the typo in the book (p. 186) • Generating n random observations from gamma distributions: rgamma(n,↵ ,1 / ) • Can also use the syntax:

pgamma(y0,shape= ↵ ,scale= ) 5/15/15 83 The R Help Page

5/15/15 84 Expected Value and Variance of the Gamma Distribution • Theorem 4.8: If Y has a gamma distribution, then E ( Y )= ↵ and V (Y )=↵2 • Proof:

5/15/15 85 Theorem 4.8 Proof Continued

5/15/15 86 Theorem 4.8 Proof Continued

5/15/15 87 Application Example

• The time between failures (in thousands of hours) of a Seasparrow missile launcher can be well modeled by a gamma distribution with ↵ =2 and =1 . • 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 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 ↵ = ⌫ / 2 and =2 – ⌫ is the Greek letter “nu” – The term “degrees of freedom” will become clear in OA3102 • Theorem 4.9: If Y has a chi-square ( 2 ) distribution with ⌫ degrees of freedom, then E ( Y )= ⌫ and V (Y )=2⌫

5/15/15 89 Interactive Chi-square Distribution Demo

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

5/15/15 90 Table 6 of Appendix 3

5/15/15 91 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, P ( Y )= p :  p – qchisq(p,⌫ ) • Generating n random observations from chi-

square distributions: rchisq(n, ⌫ )

5/15/15 92 The R Help Page

5/15/15 93 Defining the

• Definition 4.11: A random variable Y has an exponential distribution with parameter > 0 iff the density of Y is 1 y/ e , 0 y< f(y)=  1 0, elsewhere ⇢ – This is a gamma distribution with parameter ↵ =1 • Theorem 4.10: If Y has an exponential distribution, then E ( Y )= and V (Y )=2 – If is measured as the average number of time units per event then 1 / is the rate of events: the expected number of events per time period

5/15/15 94 Interactive Exponential Distribution Demo

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

5/15/15 95 Exponential R.V.s are “Memoryless”

• Exponential dist’ns have the memoryless property: If Y has an exponential distribution, with parameter > 0 , then P (Y>a+ b Y>a)=P (Y>b) | • Proof:

5/15/15 96 Proof of the Memoryless Property (cont’d)

5/15/15 97 Exponential Distribution Calculations (in R)

• The R functions for the exponential distribution:

– f (y0): dexp(y0,1 / )

– F(y0): pexp(y0,1 / ) • The pth quantile,P ( Y )= p :  p – qexp(p,1 / ) • Generating n random observations from

exponential distributions: rexp(n,1 / )

5/15/15 98 The R Help Page

5/15/15 99 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 Application Example Solution (cont’d)

• Solutions in R:

5/15/15 101 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 Section 4.7: The

• The beta distribution is a two-parameter (↵ , ) distribution defined on the interval 0 y 1   • 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 Defining the Beta Distribution

• Definition 4.12: A random variable Y has a beta distribution with parameters ↵ > 0 and > 0 iff the density of Y is ↵ 1 1 y (1 y) 0 y 1 f(y)= B(↵,)   ( 0, elsewhere where 1 ↵ 1 1 (↵)() B(↵, )= y (1 y) dy = (↵ + ) Z0 ü Don’t worry about the material in the text on the incomplete beta function

5/15/15 104 Interactive Beta Distribution Demo

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

5/15/15 105 Expected Value and Variance of the Beta Distribution • Theorem 4.11: If Y has a beta dist’n, then ↵ ↵ E ( Y )= and V (Y )= (↵ + ) (↵ + )2(↵ + + 1) • Proof:

5/15/15 106 Theorem 4.11 Proof Continued

5/15/15 107 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, P ( Y )= p :  p – qbeta(p,↵ , ) à note the typo in the book (p. 195) • Generating n random observations from beta distributions: rbeta(n, ↵, )

5/15/15 108 The R Help Page

5/15/15 109 Back to the Interactive Quantile Demo

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

5/15/15 110 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 ↵ =4 and =2 . What is the probability the FOB will use up 90% or more of the fuel in a week? • Solution:

5/15/15 111 Textbook Example 4.11 Solution (cont’d)

• Check the solution in R:

5/15/15 112 Section 4.7 Homework

• Do problems 4.115, 4.131 • Note: – For the graphs, use the R interactive application

5/15/15 113 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 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 µ k ± – It applies to any , including continuous distributions • Theorem 4.13: Let Y be a r.v. with finite mean µ and variance 2 . Then, for any constant k > 0, 1 P ( Y µ

• Proof:

5/15/15 116 Proof of Tchebysheff’s Theorem (cont’d)

5/15/15 117 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 ↵ =3 . 1 and =2 . 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 Textbook Example 4.17 Solution (cont’d)

• The exact solution:

5/15/15 119 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 ± ü µ 2 contains approx. 95% of the probability ± ü µ 3 contains almost all of the probability ± 5/15/15 120 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 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 continuous 5/15/15 121 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 2 you’ll also use the t, F, and (chi-square) distributions – All are related to the normal distribution

5/15/15 122 This Can Get Really Complicated...

5/15/15 123

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

5/15/15 124 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 with Applications, 7th edition, Thomson Brooks/Cole. 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