34
Random variables; Random variables; discrete and continuous discrete and continuous probability probability distributions distributions June 23, 2004 June 23, 2004

Random variables; discrete and continuous probability distributions June 23, 2004

  • View
    229

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Random variables; discrete and continuous probability distributions June 23, 2004

Random variables;Random variables;discrete and continuous discrete and continuous probability distributionsprobability distributions

June 23, 2004June 23, 2004

Page 2: Random variables; discrete and continuous probability distributions June 23, 2004

Random VariableRandom Variable

• A random variable x takes on a defined set of values with different probabilities.

• For example, if you roll a die, the outcome is random (not fixed) and there are 6 possible outcomes, each of which occur with probability one-sixth.

• For example, if you poll people about their voting preferences, the percentage of the sample that responds “Yes on Kerry” is a also a random variable (the percentage will be slightly differently every time you poll).

• Roughly, probability is how frequently we expect different outcomes to occur if we repeat the experiment over and over (“frequentist” view)

Page 3: Random variables; discrete and continuous probability distributions June 23, 2004

Random variables can be Random variables can be discrete or continuousdiscrete or continuous

Discrete random variables have a countable number of outcomes Examples:• Binary: Dead/alive, treatment/placebo, disease/no disease,

heads/tails• Nominal: Blood type (O, A, B, AB), marital

status(separated/widowed/divorced/married/single/common-law)

• Ordinal: (ordered) staging in breast cancer as I, II, III, or IV, Birth order—1st, 2nd, 3rd, etc., Letter grades (A, B, C, D, F)

• Counts: the integers from 1 to 6, the number of heads in 20 coin tosses

Page 4: Random variables; discrete and continuous probability distributions June 23, 2004

Continuous variableContinuous variable

A continuous random variable has an infinite continuum of possible values. – Examples: blood pressure, weight, the speed of a car,

the real numbers from 1 to 6. – Time-to-Event: In clinical studies, this is usually how

long a person “survives” before they die from a particular disease or before a person without a particular disease develops disease.

Page 5: Random variables; discrete and continuous probability distributions June 23, 2004

Probability functionsProbability functions A probability function maps the possible values of

x against their respective probabilities of occurrence, p(x)

p(x) is a number from 0 to 1.0. The area under a probability function is always 1.

Page 6: Random variables; discrete and continuous probability distributions June 23, 2004

x

p(x)

1/6

1 4 5 62 3

Discrete example: roll of a dieDiscrete example: roll of a die

xall

1 P(x)

Page 7: Random variables; discrete and continuous probability distributions June 23, 2004

Probability mass functionProbability mass function

x p(x)

1 p(x=1)=1/6

2 p(x=2)=1/6

3 p(x=3)=1/6

4 p(x=4)=1/6

5 p(x=5)=1/6

6 p(x=6)=1/61.0

Page 8: Random variables; discrete and continuous probability distributions June 23, 2004

Cumulative probabilityCumulative probability

x

P(x)

1/6

1 4 5 62 3

1/31/22/35/61.0

Page 9: Random variables; discrete and continuous probability distributions June 23, 2004

Cumulative distribution Cumulative distribution functionfunction

x P(x≤A)

1 P(x≤1)=1/6

2 P(x≤2)=2/6

3 P(x≤3)=3/6

4 P(x≤4)=4/6

5 P(x≤5)=5/6

6 P(x≤6)=6/6

Page 10: Random variables; discrete and continuous probability distributions June 23, 2004

ExamplesExamples

1. What’s the probability that you roll a 3 or less? P(x≤3)=1/2

2. What’s the probability that you roll a 5 or higher? P(x≥5) = 1 – P(x≤4) = 1-2/3 = 1/3

Page 11: Random variables; discrete and continuous probability distributions June 23, 2004

In-Class ExercisesIn-Class ExercisesWhich of the following are probability functions?

1.      f(x)=.25 for x=9,10,11,12

2.      f(x)= (3-x)/2 for x=1,2,3,4

3. f(x)= (x2+x+1)/25 for x=0,1,2,3

Page 12: Random variables; discrete and continuous probability distributions June 23, 2004

In-Class ExerciseIn-Class Exercise

1.      f(x)=.25 for x=9,10,11,12

Yes, probability function!

x f(x)

9 .25

10 .25

11 .25

12 .25

1.0

Page 13: Random variables; discrete and continuous probability distributions June 23, 2004

In-Class ExerciseIn-Class Exercise

2.      f(x)= (3-x)/2 for x=1,2,3,4

x f(x)

1 (3-1)/2=1.0

2 (3-2)/2=.5

3 (3-3)/2=0

4 (3-4)/2=-.5

Though this sums to 1, you can’t have a negative probability; therefore, it’s not a probability function.

Page 14: Random variables; discrete and continuous probability distributions June 23, 2004

In-Class ExerciseIn-Class Exercise

3. f(x)= (x2+x+1)/25 for x=0,1,2,3

x f(x)

0 1/25

1 3/25

2 7/25

3 13/25

Doesn’t sum to 1. Thus, it’s not a probability function.

24/25

Page 15: Random variables; discrete and continuous probability distributions June 23, 2004

In-Class Exercise:In-Class Exercise: The number of ships to arrive at a

harbor on any given day is a random variable represented by x. The probability distribution for x is:

x 10 11 12 13 14P(x)

.4 .2 .2 .1 .1

Find the probability that on a given day:

a.    exactly 14 ships arrive

b.    At least 12 ships arrive

c.    At most 11 ships arrive

 p(x=14)= .1

p(x12)= (.2 + .1 +.1) = .4

p(x≤11)= (.4 +.2) = .6

Page 16: Random variables; discrete and continuous probability distributions June 23, 2004

In-Class Exercise:In-Class Exercise:You are lecturing to a group of 1000 students. You ask them to each randomly pick an integer between 1 and 10. Assuming, their picks are truly random:

• What’s your best guess for how many students picked the number 9?

Since p(x=9) = 1/10, we’d expect about 1/10th of the 1000 students to pick 9. 100 students.

• What percentage of the students would you expect picked a number less than or equal to 6?

Since p(x≤ 5) = 1/10 + 1/10 + 1/10 + 1/10 + 1/10 + 1/10 =.6 60%

Page 17: Random variables; discrete and continuous probability distributions June 23, 2004

Continuous caseContinuous case The probability function that

accompanies a continuous random variable is a continuous mathematical function that integrates to 1. For example, recall the negative

exponential function (in probability, this is called an “exponential distribution”):

xexf )(

1100

0

xx ee

This function integrates to 1:

Page 18: Random variables; discrete and continuous probability distributions June 23, 2004

Continuous caseContinuous case

x

p(x)

1

The probability that x is any exact particular value (such as 1.9976) is 0; we can only assign probabilities to possible ranges of x.

Page 19: Random variables; discrete and continuous probability distributions June 23, 2004

For example, the probability of x falling within 1 to 2:

23.368.135. 2)xP(1 122

1

2

1

eeee xx

x

p(x)

1

1 2

Page 20: Random variables; discrete and continuous probability distributions June 23, 2004

Cumulative distribution Cumulative distribution functionfunction

As in the discrete case, we can specify the “cumulative distribution function” (CDF):

The CDF here = P(x≤A)=

AAAA

xA

x eeeeee 110

00

Page 21: Random variables; discrete and continuous probability distributions June 23, 2004

ExampleExample

2 x

p(x)

1

.865 .135-1 -1 2)P(x 2 e

Page 22: Random variables; discrete and continuous probability distributions June 23, 2004

Example 2: Uniform Example 2: Uniform distributiondistribution

The uniform distribution: all values are equally likely

The uniform distribution:f(x)= 1 , for 1 x 0

x

p(x)

1

1

We can see it’s a probability distribution because it integrates to 1 (the area under the curve is 1):  1011

1

0

1

0

x

Page 23: Random variables; discrete and continuous probability distributions June 23, 2004

Example: Uniform distributionExample: Uniform distribution

 What’s the probability that x is between ¼ and ½?

x

p(x)

1

1¼ ½

P(½ x ¼ )= ¼

Page 24: Random variables; discrete and continuous probability distributions June 23, 2004

In-Class ExerciseIn-Class ExerciseSuppose that survival drops off rapidly in the year following diagnosis of a certain type of advanced cancer. Suppose that the length of survival (or time-to-death) is a random variable that approximately follows an exponential distribution with parameter 2 (makes it a steeper drop off):

]1102:[

2)( :functiony probabilit

0

2

0

2

2

xx

T

eenote

eTxp

What’s the probability that a person who is diagnosed with this illness survives a year?

Page 25: Random variables; discrete and continuous probability distributions June 23, 2004

AnswerAnswerThe probability of dying within 1 year can be calculated using the cumulative distribution function: 

The chance of surviving past 1 year is: P(x≥1) = 1 – P(x≤1)

)(2

0

2 1)( TT

x eeTxP

135.)1(1 )1(2 e

 

Cumulative distribution function is:

Page 26: Random variables; discrete and continuous probability distributions June 23, 2004

Expected Value and Expected Value and VarianceVariance

All probability distributions are characterized by an expected value and a variance (standard deviation squared).

Page 27: Random variables; discrete and continuous probability distributions June 23, 2004

For example, bell-curve (normal) distribution:

Mean One standard deviation from the mean (average distance from the mean)

Page 28: Random variables; discrete and continuous probability distributions June 23, 2004

Expected value of a random Expected value of a random variable variable

If we understand the underlying probability function of a certain phenomenon, then we can make informed decisions based on how we expect x to behave on-average over the long-run…(so called “frequentist” theory of probability).

Expected value is just the weighted average or mean (µ) of random variable x. Imagine placing the masses p(x) at the points X on a beam; the balance point of the beam is the expected value of x.

Page 29: Random variables; discrete and continuous probability distributions June 23, 2004

Example: expected valueExample: expected value

Recall the following probability distribution of ship arrivals:

x 10 11 12 13 14P(x)

.4 .2 .2 .1 .1

5

1

3.11)1(.14)1(.13)2(.12)2(.11)4(.10)(i

i xpx

Page 30: Random variables; discrete and continuous probability distributions June 23, 2004

Expected value, formallyExpected value, formally

xall

)( )p(xxXE ii

Discrete case:

Continuous case:

dx)p(xxXE ii xall

)(

Page 31: Random variables; discrete and continuous probability distributions June 23, 2004

Extension to continuous Extension to continuous case:case:

example, uniform random example, uniform random variablevariable

x

p(x)

1

1

2

10

2

1

2)1()(

1

0

21

0

x

dxxXE

Page 32: Random variables; discrete and continuous probability distributions June 23, 2004

In-Class ExerciseIn-Class Exercise

3. If x is a random integer between 1 and 10, what’s the expected value of x?

5.5)1(.552

)110(10)1(.

10

1)

10

1()(

1010

1

ii

iixE

Page 33: Random variables; discrete and continuous probability distributions June 23, 2004

Variance of a random variableVariance of a random variable

If you know the underlying probability distribution, another useful concept is variance. How much does the value of x vary from its mean on average?

More on this next time…

Page 34: Random variables; discrete and continuous probability distributions June 23, 2004

Reading for this weekReading for this week

Walker: 1.1-1.2, pages 1-9