17
© 2019 McGraw-Hill Education Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g., the flipping of a coin or the random generation of a bit. Each performance of the experiment is called a Bernoulli trial. One outcome is called a success and the other a failure. If p is the probability of success and q the probability of failure, then q = 1 - p. Many problems involve determining the probability of k successes when an experiment consists of n mutually independent Bernoulli trials.

Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g., the flipping of a coin or the random generation of a bit. • Each performance of the experiment is called a Bernoulli trial. • One outcome is called a success and the other a failure. • If p is the probability of success and q the probability of failure, then

q = 1 - p.

Many problems involve determining the probability of k successeswhen an experiment consists of n mutually independent Bernoulli trials.

Page 2: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Bernoulli Trials Example: What is the probability that exactly four heads occur when a fair coin is flipped seven times?

Example: A coin is biased so that the probability of heads is 2/3. What is the probability that exactly four heads occur when the coin is flipped seven times?

Theorem: The probability of exactly k successes in n independent Bernoulli trials, with probability of success p and probability of failure q = 1 − p, is

C(n,k)pkqn−k

Page 3: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Conditional Probability revisitedDefinition: Let E and H be events with p(E) > 0. The conditional probability of H given E, denoted by p(H|E), is defined as:

S

H E

H∩E

Page 4: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

An Example with Conditional ProbabilitiesBox 1 contains three blue and seven red ballsBox 2 contains six blue and four red ballsSelect an unknown box at random, and pull out a ballYou pulled out a red ball What is the probability that you have selected Box 1?

Let E be the event that you have chosen a red ballLet H be the event that you have chosen the first box

H: HypothesisE: Evidence

Page 5: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Bayes’ Theorem

Page 6: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Bayes’ Theorem

Page 7: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Applying Bayes’ Theorem

Suppose that one person in 100,000 has a particular disease. There is a test for

the disease that gives a positive result 99% of the time when given to someone

with the disease. When given to someone without the disease, 99.5% of the

time it gives a negative result.

Find (a) the probability that a person who tests positive has the disease; and (b)

the probability that a person who tests negative does not have the disease.

Should someone who tests positive be worried?

(False negative rate = 0.01; false positive rate = 0.005)

For (a). H: the person has the disease. E: the person tests positive

For (b). H: the person does not have the disease. E: the person tests negative

Page 8: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Applying Bayes’ TheoremSolution: Let D be the event that the person has the disease, and E be the event that this person tests positive. We need to compute ( ) ( ) from , , | , .( | ) ( | ) ( )p D E p D p E D p E D p D

( )( ) 1/100,000 0.00001 1 0.00001 0.99999p pD D= = = - =

( ) ( ) ( ) ( )( ) ( ) ( )

( ) ( ) ( ) ( )( ) ( )

( ) ( ) ( ) ( )

| .99 | .01 | .005 | .995

||

| |

0.99 0.000010.99 0.00001 0.005 0.99999

0.002

p E D p E D p E D p E D

p E D p Dp D E

p E D p D p E D p D

= = = =

=+

=+

»

Can you use this formula to explain why the resulting probability is surprisingly small?

So, don’t worry too much, if your test for this disease comes back positive.

Page 9: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Applying Bayes’ TheoremWhat if the result is negative?

So, the probability you have the disease if you test negative is

( )|

1 0.9999999 0.0000001.

p D E

» -=

So, it is extremely unlikely you have the disease if you test negative.

( ) ( ) ( )( ) ( ) ( ) ( )

( ) ( )( ) ( ) ( ) ( )

||

| |

0.995 0.999990.995 0.99999 0.01 0.00001

0.9999999

p E D p Dp D E

p E D p D p E D p D=

+

=+

»

Page 10: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Generalized Bayes’ Theorem

Page 11: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Random VariablesDefinition: A random variable is a function from the sample space of an experiment to the set of real numbers. That is, a random variable assigns a real number to each possible outcome.

(A random variable is a function, not a variable. It is not “random” in the colloquial sense of the term)

Example: Suppose that a fair coin is flipped three times. Let X(t) be the random variable that equals the number of heads that appear when t is the outcome.

( ) ( )( ) ( ) ( )( ) ( ) ( )

3, 0

2,

1.

X HHH X TTT

X HHT X HTH X THH

X TTH X THT X HTT

= =

= = =

= = =

Page 12: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Random VariablesDefinition: The distribution of a random variable X on a sample space S is the set of pairs (r, p(X = r)) for all r ∊ X(S), where p(X = r) is the probability that X takes the value r.

Example: Suppose that a fair coin is flipped three times. Let X(t) be the random variable that equals the number of heads that appear when t is the outcome.

Each of the eight possible outcomes has probability 1/8. So, the distribution of X(t) is p(X = 3) = 1/8, p(X = 2) = 3/8, p(X = 1) = 3/8, and p(X = 0) = 1/8.

Page 13: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Expected Value

Definition: The expected value (or expectation or mean)

of the random variable X on the sample space S is equal to

( ) ( ) ( ) .x S

E X p s X sÎ

Example-Expected Value of a Die: Let X be the number

that comes up when a fair die is rolled. What is the

expected value of X?

Solution: The random variable X takes the values 1, 2, 3,

4, 5, or 6. Each has probability 1/6. It follows that

( ) 1 1 1 21 71 2 6 .6 6 6 6 2

E X = × + × + × = =

Page 14: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Expected ValueRESULT: The expected number of successes when nmutually independent Bernoulli trials are performed is n x p, where p is the probability of success on each trial.

Page 15: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Linearity of ExpectationsLet X and Y be random variables defined over the same sample space S. We have

E(X+Y) = E(X) + E(Y)

A generalization: Let X1, X2, …, Xn be random variables defined over the same sample space S, and a1, a2, … ,anbe any real numbers. We have

E(a1X1+ a2X2+ …+ anXn) = a1 E(X1)+ a2 E(X2)+ …+ an E(Xn)

Page 16: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Linearity of Expectations

The Hatcheck Problem: A new employee started a job checking hats, but forgot to put

the claim check numbers on the hats. So, the n customers just receive a random hat

from those remaining. What is the expected number of hats returned correctly?

Solution: Let X be the random variable that equals the number of people who receive

the correct hat.

We have X = X1 + X2 + ··· + Xn, where Xi = 1 if the ith person receives the hat and Xi = 0

otherwise.

• Because it is equally likely that the checker returns any of the hats to the ith person, it

follows that the probability that the ith person receives the correct hat is 1/n.

• Consequently for each i

( ) ( ) ( )1 1 0 0 1 1/ 0 1/ .i i iE X p X p X n n= × = + × = = × + =

• By the linearity of expectations, it follows that:

( ) ( ) ( ) ( )1 2 1/ 1.nE X E X E X E X n n= + + + = × -

Consequently, the average number of people who receive the correct hat is exactly one.

( Surprisingly, this answer remains the same no matter how many people have checked

their hats!)

“indicator random variable”

Page 17: Bernoulli Trials - research.engineering.wustl.edubaruah/TEACHING/2018-2Fa/Lecs/... · Bernoulli Trials Definition: Suppose an experiment can have only two possible outcomes, e.g.,

© 2019 McGraw-Hill Education

Linearity of ExpectationsNumber of inversions: You are give an array A[1,…,n] of n distinct integers. An inversion in this array is a pair of indices (i,j) such that A[i] > A[j].What is the expected number of inversions in a random array of n elements?Solution: Let X be the RV (random variable) that equals the number of inversions. Let Xij be the indicator RV that equals 1 if (i,j) is an inversion, and 0 otherwise