26
Discrete and Continuous Discrete and Continuous Random Variables Random Variables Summer 2003 Summer 2003

Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

Embed Size (px)

Citation preview

Page 1: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

Discrete and Continuous Discrete and Continuous Random VariablesRandom Variables

Summer 2003Summer 2003

Page 2: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 22

Random VariablesRandom VariablesA random variable is a rule that assigns a numerical value to each possible outcome of a probabilistic experiment.We denote a random variable by a capital letter (such as “X”)

Examples of random variables:

r.v. X: the age of a randomly selected student here today.

r.v. Y: the number of planes completed in the past week.

Page 3: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 33

Discrete or ContinuousDiscrete or Continuous

A A discretediscrete r.v. can take only distinct, separate r.v. can take only distinct, separate valuesvalues–– Examples?Examples?

A A continuouscontinuous r.v. can take any value in some r.v. can take any value in some interval (low,high)interval (low,high)–– Examples?Examples?

Page 4: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 44

Discrete Random VariablesDiscrete Random Variables

A probability distribution for a A probability distribution for a discretediscrete r.v. X r.v. X consists of:consists of:–– Possible values Possible values x1, x2, . . . , xn– Corresponding probabilities p1, p2, . . . , pn

with the interpretation thatp(X = x1) = p1, p(X = x2) = p2, . . . , p(X = xn) = pn

Note the following:Note the following:–– Variable names are capital letters (e.g., X)Variable names are capital letters (e.g., X)–– Values of variables are lower case letters (e.g., Values of variables are lower case letters (e.g., x1)– Each pi ≥ 0 and p1 + p2 + . . . + pn = 1.0

Page 5: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 55

Outcome X (#Hs) ProbabH3

H1H2H3 3 0.125H2 0.5

0.5T3

H1H2T3 2 0.125H1 0.5

0.5H3

H1T2H3 2 0.125T2 0.5

0.5T3

H1T2T3 1 0.1250.5

H3T1H2H3 2 0.125

H2 0.5

0.5T3

T1H2T3 1 0.125T1 0.5

0.5H3

T1T2H3 1 0.125T2 0.5

0.5T3

T1T2T3 0 0.1250.5 1.000

Probability tree and probability distribution for Probability tree and probability distribution for r.v. X (total # Heads in experiment 1)r.v. X (total # Heads in experiment 1)

P(X = 0) = 1/8P(X = 0) = 1/8

P(X = 1) = 3/8P(X = 1) = 3/8

P(X = 2) = 3/8 P(X = 2) = 3/8

P(X = 3) = 1/8P(X = 3) = 1/8

Page 6: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 66

A A histogram is a display of probabilities as a bar chartis a display of probabilities as a bar chart

r.v. X = number of heads when tossing 3 unbiased coins

x

0.00

1/8

2/8

3/8

4/8

5/8

0 1 2 3

Now let’s consider experiment 2: “number of heads when tossing Now let’s consider experiment 2: “number of heads when tossing 3 biased coins (p(H) = 0.30)”. Again r.v. X: total number of hea3 biased coins (p(H) = 0.30)”. Again r.v. X: total number of heads ds obtained when performing experiment 2…..obtained when performing experiment 2…..

Page 7: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 77

Probability tree and probability distribution for Probability tree and probability distribution for r.v. X (total # Heads in experiment 2)r.v. X (total # Heads in experiment 2)

Outcome X (#Hs) ProbabilH3

H1H2H3 3 0.027H2 0.3

0.3T3

H1H2T3 2 0.063H1 0.7

0.3H3

H1T2H3 2 0.063T2 0.3

X p(X) 0.70 0.343 T31 0.441 H1T2T3 1 0.1472 0.189 0.73 0.027

1.000H3

T1H2H3 2 0.063H2 0.3

0.3T3

T1H2T3 1 0.147T1 0.7

0.7H3

T1T2H3 1 0.147T2 0.3

0.7T3

T1T2T3 0 0.3430.7 1.000

Page 8: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 88

Histogram for experiment 2Histogram for experiment 2r.v. X = total number of heads when tossing 3 biased r.v. X = total number of heads when tossing 3 biased

coins with p(H) = 0.30. coins with p(H) = 0.30.

x

0/8

1/8

2/8

3/8

4/8

5/8

0 1 2 3

p(X)

0.343

0.441

0.189

0.027

0.0000.0500.1000.1500.2000.2500.3000.3500.4000.4500.500

0 1 2 3

p(X)

x

Page 9: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 99

Example 2: Let Let XX be the random variable that denotes the be the random variable that denotes the number of orders for aircraft for next year. Suppose that the number of orders for aircraft for next year. Suppose that the number of orders for aircraft for next year is estimated to obeynumber of orders for aircraft for next year is estimated to obey the the following distribution:following distribution:

Orders for aircraft next yearOrders for aircraft next year

xxii

ProbabilityProbabilityppii

4242 0.050.05

4343 0.100.10

4444 0.150.15

4545 0.200.20

4646 0.250.25

4747 0.150.15

4848 0.100.10

Page 10: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1010

A histogram is a display of probabilities as a bar chart A histogram is a display of probabilities as a bar chart

Probability Distribution of the Number of Orders of Aircraft Next Year

0.00

0.05

0.10

0.15

0.20

0.25

0.30

0.35

43 44 45 46 47 48

Number of Orders

Prob

abili

ty

Page 11: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1111

X and Y denote the sales next year in the eastern division and the western division of a company, respectively. X and Y obey the following distributions:

Sales($ million) Probability

3.0 0.054.0 0.205.0 0.356.0 0.307.0 0.108.0 0.00

Eastern DivisionEastern Division

Sales($ million) Probability

3.0 0.154.0 0.205.0 0.256.0 0.157.0 0.158.0 0.10

Western DivisionWestern Division Probability Distribution Function of Western Division Sales

0.00

0.05

0.10

0.15

0.20

0.25

0.30

0.35

0.40

3.0 4.0 5.0 6.0 7.0 8.0

Sales ($ million)

Pro

babi

lity

Probability Distribution Function of Eastern Division Sales

0.00

0.05

0.10

0.15

0.20

0.25

0.30

0.35

0.40

3.0 4.0 5.0 6.0 7.0 8.0

Sales ($ million)

Pro

babi

lity

Page 12: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1212

Consider two random variables X, Y, with the following histograms:

(A)(A) (B)(B)

x

P(X =x)

0.00

0.10

0.20

0.30

0.40

0.50

0 1 2 3 4 5 6

y

P(Y = y)

0.00

0.10

0.20

0.30

0.40

0.50

0 1 2 3 4 5 6

Random variable X Random variable Y

How do we describe and compare X and Y?

Page 13: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1313

Summary Statistics for a r.v.: Three important measures

- Mean or Expected Value:Represents “average” outcome; a measure of “central tendency”Represents “average” outcome; a measure of “central tendency”

- Variance:SquaredSquared deviation around the mean; a measure of “spread”deviation around the mean; a measure of “spread”

∑∑==

====n

1iiii

n

1iiX xp)xxP(X µE(X)

2X

n

1iii

2Xi

n

1iiX

2 )µ(xp)µ)(xxP(X σVar(X) −=−=== ∑∑==

- Standard Deviation :Square root of the variance. A measure of spread in the easure of spread in the same unitssame unitsas the random variable X.as the random variable X.

2XX σ σ SD(X) ==

Page 14: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1414

Example: Let X be the number that comes up on a roll of one die.

Compute the mean, variance and standard deviation of X.

Outcome P(X=x)

1 1/6

2 1/6

3 1/6

4 1/6

5 1/6

6 1/6

µx= 1/6*1 +1/6 *2 +1/6 *3 + 1/6*4+1/6*5+1/6*6 = 3.5

(σx)2= 1/6*(1-3.5)2 +1/6 *(2-3.5) 2 +1/6 *(3-3.5) 2 + 1/6 *(4-3.5) 2

+1/6 *(4-3.5) 2 +1/6 *(5-3.5) 2 +1/6 *(6-3.5) 2 = 2.917

σx= Sqrt{2.917}= 1.708

Page 15: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1515

Example 2:

Compute the mean, variance ,standard deviation of X (eastern division sales) and Y (western division sales)

mil 2.5$=Xµ

22 mil 1.06 =Xσ

mil 1.029$ =Xσ

mil 25.5$ =Y

µ

22 mil 3875.2=Yσ

milY 545.1$=σ

Page 16: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1616

Continuous Random Variables

A continuous random variable can take any value in some interval Example: X = time a customer spends waiting in line at the store

• “Infinite” number of possible values for the random variable. How can we describe a probability distribution? (We can no longer list the pi’s and xi’s!)

• For a continuous random variable, questions are phrased in terms of a range of values.

Example: We might talk about the event that a customer waits between 5.0 and 10.0 minutes, and not about the event that a customer waits exactly 5.25 minutes! (why?)

Page 17: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1717

Continuous Probability Distributions Continuous Probability Distributions Continuous Probability Distributions Continuous R.V.’s have continuousContinuous R.V.’s have continuous probability probability distributions known also as the distributions known also as the probability density probability density function (PDF)function (PDF)Since a continuous R.V. X can take an Since a continuous R.V. X can take an infiniteinfinitenumber of values on an interval, the probability that a number of values on an interval, the probability that a continuous R.V. X takes any single given value is continuous R.V. X takes any single given value is zerozero: P(X=c)=0: P(X=c)=0Probabilities for a continuous RV X are calculated for Probabilities for a continuous RV X are calculated for a range of values: P (a a range of values: P (a ≤≤ X X ≤≤ b) b) P (a P (a ≤≤ X X ≤≤ b) is the area under b) is the area under

the probability distribution function, the probability distribution function, f(x)f(x) , for continuous R.V. X., for continuous R.V. X.

The total area under The total area under f(x)f(x) is 1.0is 1.0a b c

Page 18: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1818

The Uniform Distribution

a) What is the mean transit time?

X is uniform on [a,b] if X is equally likely to take any value in the range from a to b.

E(X) = µx = ?

Example: Suppose that transit time of the subway between Alewife Station and Downtown Crossing is uniformly distributed between

10.0 and 20.0 minutes.

b) What is the probability that the transit time exceeds 12.0 minutes?

c) What is the probability that the transit time is between 14.0 and 18.0 minutes?

P(X >= 12.0) = ?

P(14<= X <= 18) = ?

Page 19: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 1919

Uniform DistributionUniform DistributionUniform Distribution

f xb a

for a x b

for( ) =

−≤ ≤

⎨⎪⎪

⎩⎪⎪

1

0 all other values

Area = 1

f x( )

x

1b a−

a b

A continuous R.V. X is uniform in the interval [aA continuous R.V. X is uniform in the interval [a--b] b] if it is equally likely to take any value in the interval if it is equally likely to take any value in the interval [a,b]. Thus f(x) for a continuous uniform R.V. is a [a,b]. Thus f(x) for a continuous uniform R.V. is a horizontal line (i.e., a constant). f(x)=1/(bhorizontal line (i.e., a constant). f(x)=1/(b--a) so a) so that the area under the curve is 1.0.that the area under the curve is 1.0.

Page 20: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 2020

Uniform DistributionUniform DistributionUniform Distribution

⎪⎪⎩

⎪⎪⎨

⎧ ≤≤−

=esother valu all0

20101020

1

)(for

xfor

xf

transit time of the subway between Alewife transit time of the subway between Alewife Station and Downtown Crossing is uniformly Station and Downtown Crossing is uniformly distributed between 10.0 and 20.0 minutes.distributed between 10.0 and 20.0 minutes.

Area = 1

f x( )

x

1b a−10

2010P(X >= 12.0) = 0.80

P(14<= X <= 18) = 0.40

Page 21: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 2121

Lot Weights in a Warehouse are Uniformly distributed Between 41 and 47 lbs.

Lot Weights in a Warehouse are Uniformly Lot Weights in a Warehouse are Uniformly distributed Between 41 and 47 lbs.distributed Between 41 and 47 lbs.

f xfor x

for( ) =

−≤ ≤

⎨⎪⎪

⎩⎪⎪

147 41

41 47

0 all other values

Area = 1

f x( )

x

147 41

16−

=

41 47

Page 22: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 2222

What is the probability that the weight of a randomly selected lot is between 42 and 45 lbs?

What is the probability that the weight of a What is the probability that the weight of a randomly selected lot is between 42 and 45 lbs?randomly selected lot is between 42 and 45 lbs?

( )xxxx abXP

1221

1)( −−

=≤≤

( )21

614245)4542( =−=≤≤ XP

f x( )

x41 4742 45

( )21

614245 =−

Area= 0.5

6/1

Page 23: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 2323

Uniform Distribution Mean and Standard Deviation

Uniform Distribution Uniform Distribution Mean and Standard DeviationMean and Standard Deviation

Mean

= +µ a b2

Mean

= +µ 41 472

882

44= =

Standard Deviation

σ =−b a12

Standard Deviation

σ =−

= =47 41

126

3 4641 732

..

Page 24: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 2424

Cumulative Distribution Function (CDF)

)()()( tFdxxftXPt

==≤ ∫∞−

tt

1.0

0.0

F(t)

t

)()( sXPsF ≤=)( sXP ≤

1.0

0.0

F(s)

ss

)()()()()( sFtFsXPtXPtXsP −=<−≤=≤≤

Page 25: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 2525

Let X be uniformly distributed on [a,b]. Then density Let X be uniformly distributed on [a,b]. Then density function of X is: function of X is:

Find the CDF:Find the CDF:

F(x)F(x)

a a bb

11

f xb a

for a x b

for( ) =

−≤ ≤

⎨⎪⎪

⎩⎪⎪

1

0 all other values

aa bb

1/(b1/(b--a)a)

f(x)f(x)

⎪⎪

⎪⎪

><

≤≤−

−−

=bxforax

bxaforaab

xab

xF10

)(1

)(1

)(

∫∞−

=x

duufxF )()(

Page 26: Discrete and Continuous Random Variables - MIT · PDF fileDiscrete and Continuous Random Variables Summer 2003. 15.063 Summer 2003 22 Random Variables A random variableis a rule that

15.063 Summer 200315.063 Summer 2003 2626

SummarySummary

Discrete and continuous random variables Discrete and continuous random variables have to be understood differentlyhave to be understood differentlyHistograms are very useful for discrete Histograms are very useful for discrete variablesvariablesNext session we will talk about “binomial” Next session we will talk about “binomial” distributionsdistributionsUniform continuous random variables are Uniform continuous random variables are a good place to start for our later work with a good place to start for our later work with normal distributions etc.normal distributions etc.