Lecture (7)

47
Lecture (7) Lecture (7) Random Variables Random Variables and and Distribution Distribution Functions Functions

description

Lecture (7). Random Variables and Distribution Functions. Random Variables. Parameter that cannot be predicted with certainty Outcome of a random or uncertain process - flipping a coin or picking out a card from deck Can be discrete or continuous Data are usually discrete or quantized - PowerPoint PPT Presentation

Transcript of Lecture (7)

Page 1: Lecture (7)

Lecture (7)Lecture (7)

Random Variables Random Variables and and

Distribution FunctionsDistribution Functions

Page 2: Lecture (7)

Random Variables

• Parameter that cannot be predicted with certainty

• Outcome of a random or uncertain process - flipping a coin or picking out a card from deck

• Can be discrete or continuous

• Data are usually discrete or quantized

• Usually easier to apply continuous distribution to discrete data that has been organized into bins

Page 3: Lecture (7)

• A random variable is discrete if it can assume a countable number of values.

• A random variable is continuous if it can assume an uncountable number of values.

0 11/21/41/16

Continuous random variableAfter the first value is definedthe second value, and any valuethereafter are known.

Therefore, the number of values is countable

After the first value is defined,any number can be the next one

Discrete random variable

Therefore, the number of values is uncountable

0 1 2 3 ...

Discrete and Continuous Random Variables

Page 4: Lecture (7)

A probability distribution of X provides the probability of each possible value of the random variable. If PX(x) is the

probability that x is the value of the random variable, we know that and that where the summation is over all values that X takes on. This is because these values of X are mutually exclusive and one of them must occur.

1)(P0 X x 1)(PX x

Probability distribution

Page 5: Lecture (7)

The sum of numbers showing on two true dices.

0

1

2

3

4

5

6

7

0 1 2 3 4 5 6 7

X 2 3 4 5 6 7 8 9 10 11 12 Total

PX(x) 136

1

36

1

36

2

36

2

36

3

36

3

36

4

36

4

36

5

36

5

36

6

7 8 9 10 11 12

6 7 8 9 10 11

5 6 7 8 9 10

4 5 6 7 8 9

3 4 5 6 7 8

2 3 4 5 6 7

Examples Probability distribution

0

1

2

3

4

5

6

7

0 1 2 3 4 5 6 7

1 2 3 4 5 6

5

4

3

2

1

2

3

4

5

6

7 8 9 10 11 12

Page 6: Lecture (7)

The probability distribution can be also presented by a graph.

0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0.16

0.18

2 3 4 5 6 7 8 9 10 11 12

Sum of numbmers

Pro

bab

ilit

y

And by a mathematical function:36

76)(PX

xx

Page 7: Lecture (7)

Graphical Representation of pdf and Graphical Representation of pdf and cdfcdf

Page 8: Lecture (7)

Examples of Discrete Probability Examples of Discrete Probability DistributionsDistributions

Uniform Discrete Distribution

Bernoulli Distribution

Binomial Distribution

Poisson Distribution

Page 9: Lecture (7)

Uniform Distribution (Discrete Case)Uniform Distribution (Discrete Case)

1, 1, 2,3,.....,

( )0

k np k n

Example: throwing a die.

All 6 faces of a die:

X 1 2 3 4 5 6 Total

PX(x) 1/6 1/6 1/6 1/6 1/6 1/6 1

Page 10: Lecture (7)

Bernoulli DistributionBernoulli Distribution

The random variable X that takes the values 0 or 1 with probability 1-p and q respectively, i.e.

Pr( 0) (1 )

Pr( 1)

X q p

X p

is called a Bernoulli Variable.

Example: throwing the coin.

Page 11: Lecture (7)

Bernoulli Example

•Probability distribution•Values probability

• 0 1/4 = .25

• 1 2/4 = .50

• 2 1/4 = .25

Event: Toss 2 Coins. Count # Tails.

T

T

T T

Page 12: Lecture (7)

The Binomial Distribution

• The binomial experiment can result in only one of two possible outcomes.

• Typical cases where the binomial experiment applies:– A coin flipped results in heads or tails– An election candidate wins or loses– An employee is male or female

Page 13: Lecture (7)

Binomial Distribution: B(n,p) Binomial Distribution: B(n,p)

Consider a random sequence of n Bernoulli trials, each with: Probability of success = pProbability of failure = q= 1-p we evaluate the number of r success in the n trials by the number of combinations. An outcome of the experiment like,

times times

... ...

There are of such combinations

each having a probaility

!Pr( ) , 0,1,...,

!( )!

r n r

r n r

r n r

r n r r n r

sss ss fff ff

p q

n

r

p q

n nX r p q p q r n

r r n r

Example: throwing the coin several times (n times).

Page 14: Lecture (7)

– There are n trials (n is finite and fixed).– Each trial can result in a success or a failure.– The probability p of success is the same for all

the trials.– All the trials of the experiment are independent.

• Binomial Random Variable– The binomial random variable counts the

number of successes in n trials of the binomial experiment.

– By definition, this is a discrete random variable.

Binomial Experiment

Page 15: Lecture (7)

S1

S2

S2

F2

F1

F2

S3

S3

S3

S3

F3

F3

F3

F3

P(SSS)=p3

P(SSF)=p2(1-p)

P(SFS)=p(1-p)p

P(SFF)=p(1-p)2

P(FSS)=(1-p)p2

P(FSF)=(1-p)p(1-p)P(FFS)=(1-p)2p

P(FFF)=(1-p)3

P(S 1)=p

P(S2|S1)

P(F1 )=1-p

P(F2 |S

1)

P(S2|F1)

P(F2 |F

1)

P(S2)=p

P(F2)=1-p

P(S2)=p

P(F2 )=1-p

P(S3|S2,S1)

P(F3|S2,S1)

P(S3|F2,S1)

P(F3|F2,S1)

P(S3|S2,F1)

P(S3|F2,F1)

P(F3|F2,F1)

P(F3|S2,F1)

P(S3)=p

P(S3)=p

P(S3)=p

P(S3)=p

P(F3)=1-p

P(F3)=1-p

P(F3)=1-p

P(F3)=1-p

Since the outcome of each trial is independent of the previous outcomes, we can replace the conditional probabilities with the marginal probabilities.

Since the outcome of each trial is independent of the previous outcomes, we can replace the conditional probabilities with the marginal probabilities.

P(S2|S1

Developing the Binomial Probability Distribution (n = 3)

Page 16: Lecture (7)

P(SSS)=p3

P(SSF)=p2(1-p)

P(SFS)=p(1-p)p

P(SFF)=p(1-p)2

P(FSS)=(1-p)p2

P(FSF)=(1-p)p(1-p)P(FFS)=(1-p)2p

P(FFF)=(1-p)3

Let X be the number of successes in three trials. Then,

X = 3

X =2

X = 1

X = 0

P(X = 3) = p3

P(X = 2) = 3p2(1-p)

P(X = 1) = 3p(1-p)2

P(X = 0) = (1- p)3

This multiplier is calculated in the following formula

SSS

SS

S S

SS

Developing the Binomial Probability Distribution (n = 3)

Page 17: Lecture (7)

Calculating the Binomial Probability

xnxnx )p1(pC)x(p)xX(P xnxn

x )p1(pC)x(p)xX(P

In general, The binomial probability is calculated by:

)!xn(!x!n

Cwhere nx

Page 18: Lecture (7)

• Example– A student is registered in a statistics course and

intends to rely on luck to pass the next quiz.– The quiz consists on 10 multiple choice

questions with 5 possible choices for each question, only one of which is the correct answer.

– The student will guess the answer to each question

– Find the following probabilities• The student gets no answer correct• The student gets two answer correct?• The student fails the quiz

Calculating the Binomial Probability

Page 19: Lecture (7)

• Solution– Checking the conditions

• An answer can be either correct or incorrect.

• There is a fixed finite number of trials (n=10)

• Each answer is independent of the others.• The probability p of a correct answer (.20)

does not change from question to question.

Calculating the Binomial Probability

Page 20: Lecture (7)

• Solution – Continued – Determining the binomial probabilities:

Let X = the number of correct answers

Calculating the Binomial Probability

1074.)80(.)20(.)!010(!0

!10)0( 0100

XP

3020.)80(.)20(.)!210(!2

!10)2( 2102

XP

Page 21: Lecture (7)

= p(0) + p(1) + p(2) + p(3) + p(4) = .1074 + .2684 + .3020 + .2013 + .0881 =.9672

• Solution – Continued – Determining the binomial probabilities:

the student fails the test if the number of correct answers is less than 5, which means less than or equal to 4.

Calculating the Binomial Probability

This is called cumulative probability

P(X4

Page 22: Lecture (7)

E(X) = = np

V(X) = 2 = np(1-p)

• Example– If all the students in class intend to guess

the answers to the quiz, what is the mean and the standard deviation of the quiz mark?

• Solution– m = np = 10(.2) = 2.– s = [np(1-p)]1/2 = [10(.2)(.8)]1/2 = 1.26.

Mean and Variance of Binomial Variable

Page 23: Lecture (7)

Binomial Distribution B(n,p)

Page 24: Lecture (7)

Binomial distribution for n=4 and p=0.9

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

1 2 3 4

Values of X

Pro

ba

bilit

y

Binomial distribution for n=10 and p=0.9

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

1 2 3 4 5 6 7 8 9 10

Values of X

Pro

ba

bilit

y

Chart 1

Chart 2

xnxnx )p1(pC)x(p)xX(P xnxn

x )p1(pC)x(p)xX(P

Page 25: Lecture (7)

Binomial distribution for n=20 and p=0.9

0

0.05

0.1

0.15

0.2

0.25

0.3

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Values of X

Pro

bab

ilit

y

Binomial distribution for n=40 and p=0.9

0

0.05

0.1

0.15

0.2

0.25

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39

Values of X

Pro

ba

bil

ity

Chart 3

Chart 4

xnxnx )p1(pC)x(p)xX(P xnxn

x )p1(pC)x(p)xX(P

Page 26: Lecture (7)

Binomial distribution for n=80 and p=0.9

0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0.16

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77

Values of X

Pro

bab

ilit

y

Binomial distribution for n=160 and p=0.9

0

0.02

0.04

0.06

0.08

0.1

0.12

1 11 21 31 41 51 61 71 81 91 101 111 121 131 141 151

Values of X

Pro

ba

bil

ity

Chart 5

Chart 6

xnxnx )p1(pC)x(p)xX(P xnxn

x )p1(pC)x(p)xX(P

Page 27: Lecture (7)

Binomial distribution for n=160 and p=0.7

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

1 11 21 31 41 51 61 71 81 91 101 111 121 131 141 151

Values of X

Pro

ba

bil

ity

Binomial distribution for n=160 and p=0.5

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

1 11 21 31 41 51 61 71 81 91 101 111 121 131 141 151

Values of X

Pro

ba

bilit

y

Chart 7

Chart 8

xnxnx )p1(pC)x(p)xX(P xnxn

x )p1(pC)x(p)xX(P

Page 28: Lecture (7)

Binomial distribution for n=160 and p=0.25

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

1 11 21 31 41 51 61 71 81 91 101 111 121 131 141 151

Values of X

Pro

ba

bil

ity

Chart 9

xnxnx )p1(pC)x(p)xX(P xnxn

x )p1(pC)x(p)xX(P

Page 29: Lecture (7)

• The Poisson experiment typically fits cases of rare events that occur over a fixed amount of time or within a specified region

• Typical cases– The number of errors a typist makes per page– The number of customers entering a service

station per hour– The number of telephone calls received by a

switchboard per hour.– The number of Rainy days in Jeddah within a

year.

Poisson Distribution

Page 30: Lecture (7)

• The number of successes (events) that occur in a certain time interval is independent of the number of successes that occur in another time interval.

• The probability of a success in a certain time interval is: the same for all time intervals of the same size, proportional to the length of the interval.

• The probability that two or more successes will occur in an interval approaches zero as the interval becomes smaller.

Properties of the Poisson Experiment

Page 31: Lecture (7)

• The Poisson Random Variable– The Poisson variable indicates the number

of successes that occur during a given time interval or in a specific region in a Poisson experiment

• Probability Distribution of the Poisson Random Variable.

)X(V)X(E

...2,1,0x!x

e)x(p)xX(P

x

The Poisson Variable and Distribution

Page 32: Lecture (7)

Poisson Distributions (Graphs)

0

0.1

0.2

0.3

0.4

1 2 3 4 5 6 7 8 9 10 11

3678.e!01e

)0(p)0X(P 101

3678.e!11e

)1(p)1X(P 111

1839.2

e!21e

)2(p)2X(P121

0613.6

e!31e

)3(p)3X(P131

0 1 2 3 4 5

Page 33: Lecture (7)

Poisson Distributions (Graphs)

0

0.05

0.1

0.15

0.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

0

0.05

0.1

0.15

0.2

1 2 3 4 5 6 7 8 9 10 11

00.050.1

0.150.2

0.250.3

1 2 3 4 5 6 7 8 9 10 11

Poisson probability distribution with =2

Poisson probability distribution with =5

Poisson probability distribution with =7

0 1 2 3 4 5 6

0 1 2 3 4 5 6 7 8 9 10

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Page 34: Lecture (7)

Poisson Distribution (Example 1)

• Example– The number of Typographical errors in new

editions of textbooks is Poisson distributed with a mean of 1.5 per 100 pages.

– 100 pages of a new book are randomly selected.

– What is the probability that there are no typos?

• Solution– P(X=0)=

e-x

x!e-1.51.50

0! .2231= =

Page 35: Lecture (7)

Poisson Distribution (Example 2)

• Example– For a 400 page book calculate the following

probabilities• There are no typos• There are five or fewer typos

• Solution– P(X=0)=– P(X5)=<use the formula to find p(0), p(1),

…,p(5), then calculate p(0)+p(1)+…+p(5) = .4457

e-x

x!e-660

0! .002479= =

Important!A mean of 1.5 typos per100 pages, is equivalent to 6 typosper 400 pages.

Page 36: Lecture (7)

The difference between Binomial and Poisson distributions.

The parameter p and n in the Poisson distribution are dependent.

The Binomial distribution is bounded by X=0, X=n with p(X=0)=(1-p)^n and p(X=n)=p^n

The Poisson distribution is bounded by X=0 for p(X=0)=e^-

The Poisson distribution only the occurrence of an event can be counted; the number of its non-occurrences cannot.

Page 37: Lecture (7)

• The bivariate (or joint) distribution is used when the relationship between two random variables is studied.

• The probability that X assumes the value x, and Y assumes the value y is denoted

p(x,y) = P(X=x and Y = y)

Discrete Bivariate Distributions

Page 38: Lecture (7)

Bivariate Distributions

1y)p(x, 2.

1y)p(x,0 1.

:conditionsfollowingthesatisfies

function y probabilitjoint The

y all

xall

Page 39: Lecture (7)

• Example– X and Y are two variables. Let X and Y

denote the runoff and the raifall, respectively.

– The bivariate probability distribution is presented next.

Bivariate Distributions

Page 40: Lecture (7)

p(x,y)

Bivariate Distributions

X

YX=0 X=2X=1

y=1

y=2

y=0

0.42

0.120.21

0.070.06

0.02

0.06

0.03

0.01

Example continued X

Y 0 1 20 .12 .42 .061 .21 .06 .032 .07 .02 .01

Page 41: Lecture (7)

Marginal Probabilities

• Example- continued– Sum across rows and down columns

XY 0 1 2 p(y)0 .12 .42 .06 .601 .21 .06 .03 .302 .07 .02 .01 .10p(x) .40 .50 .10 1.00

p(0,0)p(0,1)p(0,2)

The marginal probability P(X=0)

P(Y=1), the marginal probability.

Page 42: Lecture (7)

)yY(P)yYandxX(P

)yY|xX(P

)yY(P)yYandxX(P

)yY|xX(P

1.30.03.

)1Y(P)1Yand2X(P

)1Y|2X(P

2.30.06.

)1Y(P)1Yand1X(P

)1Y|1X(P

7.30.21.

)1Y(P)1Yand0X(P

)1Y|0X(P

Example - continued

The sum is equal to 1.0

XY 0 1 2 p(y)0 .12 .42 .06 .601 .21 .06 .03 .302 .07 .02 .01 .10p(x) .40 .50 .10 1.00

Conditional Probability

Page 43: Lecture (7)

Excel Application

• See Excel

Page 44: Lecture (7)

Probability Calculation

• Probability: Numerical measure of the likelihood that an event will occur

• Some probabilities that can be calculated using Excel:– Binomial Probabilities– Poisson Probabilities– Hypergeometric Probabilities– Normal Probabilities– Exponential Probabilities

Page 45: Lecture (7)

Binomial Probabilities

• Use BINOMDIST to compute binomial distribution probabilities and cumulative binomial probabilitiesCell =BINOMDIST(number_s, trials, probability_s,

cumulative)– Calculates the probability that a sequence of

independent trials with two possible outcomes will have a given number of successes

– Cumulative is either TRUE or FALSE

Page 46: Lecture (7)

Poisson Probabilities

• Use POISSON to compute Poisson ProbabilitiesCell = POISSON (x, mean, cumulative)– Shows the probability of x occurrences of an

event over a specified interval of time or space

Page 47: Lecture (7)

Hypergeometric Probabilities

• Use HYPGEOMDIST to compute hypergeometric probabilitiesCell =HYPGEOMDIST(sample_s, number_sample,

population_s, number_pop)– Computes the probability of x successes

(sample_s) in n trials (number_sample) when the trials are dependent

– Similar to Binomial except trials are not independent – probability of success changes from trial to trial

– Does not compute cumulative probabilities