Lecture Notes 1 Basic Probability - Stanford...

28
Lecture Notes 1 Basic Probability Set Theory Elements of Probability Conditional probability Sequential Calculation of Probability Total Probability and Bayes Rule Independence Counting EE 178/278A: Basic Probability Page 1 – 1 Set Theory Basics A set is a collection of objects, which are its elements ω A means that ω is an element of the set A A set with no elements is called the empty set, denoted by Types of sets: Finite: A = {ω 1 2 ,...,ω n } Countably infinite: A = {ω 1 2 ,...}, e.g., the set of integers Uncountable: A set that takes a continuous set of values, e.g., the [0, 1] interval, the real line, etc. A set can be described by all ω having a certain property, e.g., A = [0, 1] can be written as A = {ω :0 ω 1} A set B A means that every element of B is an element of A A universal set Ω contains all objects of particular interest in a particular context, e.g., sample space for random experiment EE 178/278A: Basic Probability Page 1 – 2

Transcript of Lecture Notes 1 Basic Probability - Stanford...

Page 1: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Lecture Notes 1

Basic Probability

• Set Theory

• Elements of Probability

• Conditional probability

• Sequential Calculation of Probability

• Total Probability and Bayes Rule

• Independence

• Counting

EE 178/278A: Basic Probability Page 1 – 1

Set Theory Basics

• A set is a collection of objects, which are its elements

ω ∈ A means that ω is an element of the set A

A set with no elements is called the empty set, denoted by ∅

• Types of sets:

Finite: A = ω1, ω2, . . . , ωn

Countably infinite: A = ω1, ω2, . . ., e.g., the set of integers

Uncountable: A set that takes a continuous set of values, e.g., the [0, 1]interval, the real line, etc.

• A set can be described by all ω having a certain property, e.g., A = [0, 1] can bewritten as A = ω : 0 ≤ ω ≤ 1

• A set B ⊂ A means that every element of B is an element of A

• A universal set Ω contains all objects of particular interest in a particularcontext, e.g., sample space for random experiment

EE 178/278A: Basic Probability Page 1 – 2

Page 2: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Set Operations

• Assume a universal set Ω

• Three basic operations:

Complementation: A complement of a set A with respect to Ω isAc = ω ∈ Ω : ω /∈ A, so Ωc = ∅

Intersection: A ∩B = ω : ω ∈ A and ω ∈ B

Union: A ∪B = ω : ω ∈ A or ω ∈ B

• Notation:

∪ni=1Ai = A1 ∪A2 . . . ∪An

∩ni=1Ai = A1 ∩A2 . . . ∩An

• A collection of sets A1, A2, . . . , An are disjoint or mutually exclusive ifAi ∩Aj = ∅ for all i 6= j , i.e., no two of them have a common element

• A collection of sets A1, A2, . . . , An partition Ω if they are disjoint and∪ni=1Ai = Ω

EE 178/278A: Basic Probability Page 1 – 3

• Venn Diagrams

(e) A ∩ B (f) A ∪ B

(b) A

(d) Bc

(a) Ω

(c) B

EE 178/278A: Basic Probability Page 1 – 4

Page 3: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Algebra of Sets

• Basic relations:

1. S ∩ Ω = S

2. (Ac)c = A

3. A ∩Ac = ∅

4. Commutative law: A ∪B = B ∪A

5. Associative law: A ∪ (B ∪ C) = (A ∪B) ∪ C

6. Distributive law: A ∩ (B ∪ C) = (A ∩B) ∪ (A ∩ C)

7. DeMorgan’s law: (A ∩B)c = Ac ∪Bc

DeMorgan’s law can be generalized to n events:

(∩ni=1Ai)

c= ∪n

i=1Aci

• These can all be proven using the definition of set operations or visualized usingVenn Diagrams

EE 178/278A: Basic Probability Page 1 – 5

Elements of Probability

• Probability theory provides the mathematical rules for assigning probabilities tooutcomes of random experiments, e.g., coin flips, packet arrivals, noise voltage

• Basic elements of probability:

Sample space: The set of all possible “elementary” or “finest grain”outcomes of the random experiment (also called sample points)– The sample points are all disjoint– The sample points are collectively exhaustive, i.e., together they make upthe entire sample space

Events: Subsets of the sample space

Probability law : An assignment of probabilities to events in a mathematicallyconsistent way

EE 178/278A: Basic Probability Page 1 – 6

Page 4: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Discrete Sample Spaces

• Sample space is called discrete if it contains a countable number of samplepoints

• Examples:

Flip a coin once: Ω = H, T

Flip a coin three times: Ω = HHH,HHT,HTH, . . . = H,T3

Flip a coin n times: Ω = H,Tn (set of sequences of H and T of length n)

Roll a die once: Ω = 1, 2, 3, 4, 5, 6

Roll a die twice: Ω = (1, 1), (1, 2), (2, 1), . . . , (6, 6) = 1, 2, 3, 4, 5, 62

Flip a coin until the first heads appears: Ω = H,TH, TTH, TTTH, . . .

Number of packets arriving in time interval (0, T ] at a node in acommunication network : Ω = 0, 1, 2, 3, . . .

Note that the first five examples have finite Ω, whereas the last two havecountably infinite Ω. Both types are called discrete

EE 178/278A: Basic Probability Page 1 – 7

• Sequential models: For sequential experiments, the sample space can bedescribed in terms of a tree, where each outcome corresponds to a terminalnode (or a leaf)

Example: Three flips of a coin

|

H

|

H

|

@@@@@@

T|

AAAAAAAAAAA

T

|

H

|

@@@@@@

T|

HHHHHHHT

HHHHHHHT

HHHHHHHT

HHHHHHHT

|HHH

|HHT

|HTH

|HTT

|THH

|THT

|TTH

|TTT

EE 178/278A: Basic Probability Page 1 – 8

Page 5: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

• Example: Roll a fair four-sided die twice.

Sample space can be represented by a tree as above, or graphically

f

f

f

f

f

f

f

f

f

f

f

f

f

f

f

f

2nd roll

1st roll

1

2

3

4

1 2 3 4

EE 178/278A: Basic Probability Page 1 – 9

Continuous Sample Spaces

• A continuous sample space consists of a continuum of points and thus containsan uncountable number of points

• Examples:

Random number between 0 and 1: Ω = [0, 1]

Suppose we pick two numbers at random between 0 and 1, then the samplespace consists of all points in the unit square, i.e., Ω = [0, 1]2

6

-

1.0

1.0x

y

EE 178/278A: Basic Probability Page 1 – 10

Page 6: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Packet arrival time: t ∈ (0,∞), thus Ω = (0,∞)

Arrival times for n packets: ti ∈ (0,∞), for i = 1, 2, . . . , n, thus Ω = (0,∞)n

• A sample space is said to be mixed if it is neither discrete nor continuous, e.g.,Ω = [0, 1] ∪ 3

EE 178/278A: Basic Probability Page 1 – 11

Events

• Events are subsets of the sample space. An event occurs if the outcome of theexperiment belongs to the event

• Examples:

Any outcome (sample point) is an event (also called an elementary event),e.g., HTH in three coin flips experiment or 0.35 in the picking of arandom number between 0 and 1 experiment

Flip coin 3 times and get exactly one H. This is a more complicated event,consisting of three sample points TTH, THT, HTT

Flip coin 3 times and get an odd number of H’s. The event isTTH, THT, HTT, HHH

Pick a random number between 0 and 1 and get a number between 0.0 and0.5. The event is [0, 0.5]

• An event might have no points in it, i.e., be the empty set ∅

EE 178/278A: Basic Probability Page 1 – 12

Page 7: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Axioms of Probability

• Probability law (measure or function) is an assignment of probabilities to events(subsets of sample space Ω) such that the following three axioms are satisfied:

1. P(A) ≥ 0, for all A (nonnegativity)

2. P(Ω) = 1 (normalization)

3. If A and B are disjoint (A ∩B = ∅), then

P(A ∪B) = P(A) + P(B) (additivity)

More generally,

3’. If the sample space has an infinite number of points and A1, A2, . . . aredisjoint events, then

P (∪∞i=1Ai) =

∞∑

i=1

P(Ai)

EE 178/278A: Basic Probability Page 1 – 13

• Mimics relative frequency, i.e., perform the experiment n times (e.g., roll a die ntimes). If the number of occurances of A is nA, define the relative frequency ofan event A as fA = nA/n

Probabilities are nonnegative (like relative frequencies)

Probability something happens is 1 (again like relative frequencies)

Probabilities of disjoint events add (again like relative frequencies)

• Analogy: Except for normalization, probability is a measure much like

mass

length

area

volume

They all satisfy axioms 1 and 3

This analogy provides some intuition but is not sufficient to fully understandprobability theory — other aspects such as conditioning, independence, etc.., areunique to probability

EE 178/278A: Basic Probability Page 1 – 14

Page 8: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Probability for Discrete Sample Spaces

• Recall that sample space Ω is said to be discrete if it is countable

• The probability measure P can be simply defined by first assigning probabilitiesto outcomes, i.e., elementary events ω, such that:

P(ω) ≥ 0, for all ω ∈ Ω, and∑

ω∈Ω

P(ω) = 1

• The probability of any other event A (by the additivity axiom) is simply

P(A) =∑

ω∈A

P(ω)

EE 178/278A: Basic Probability Page 1 – 15

• Examples:

For the coin flipping experiment, assign

P(H) = p and P(T) = 1− p, for 0 ≤ p ≤ 1

Note: p is the bias of the coin, and a coin is fair if p = 12

For the die rolling experiment, assign

P(i) =1

6, for i = 1, 2, . . . , 6

The probability of the event “the outcome is even”, A = 2, 4, 6, is

P(A) = P(2) + P(4) + P(6) =1

2

EE 178/278A: Basic Probability Page 1 – 16

Page 9: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

If Ω is countably infinite, we can again assign probabilities to elementaryeventsExample: Assume Ω = 1, 2, . . ., assign probability 2−k to event kThe probability of the event “the outcome is even”

P( outcome is even ) = P(2, 4, 6, 8, . . .)

= P(2) + P(4) + P(6) + . . .

=∞∑

k=1

P(2k)

=∞∑

k=1

2−2k =1

3

EE 178/278A: Basic Probability Page 1 – 17

Probability for Continuous Sample Space

• Recall that if a sample space is continuous, Ω is uncountably infinite

• For continuous Ω, we cannot in general define the probability measure P by firstassigning probabilities to outcomes

• To see why, consider assigning a uniform probability measure to Ω = (0, 1]

In this case the probability of each single outcome event is zero

How do we find the probability of an event such as A =[

12,

34

]

?

• For this example we can define uniform probability measure over [0, 1] byassigning to an event A, the probability

P(A) = length of A,

e.g., P([0, 1/3] ∪ [2/3, 1]) = 2/3

Check that this is a legitimate assignment

EE 178/278A: Basic Probability Page 1 – 18

Page 10: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

• Another example: Romeo and Juliet have a date. Each arrives late with arandom delay of up to 1 hour. Each will wait only 1/4 of an hour before leaving.What is the probability that Romeo and Juliet will meet?

Solution: The pair of delays is equivalent to that achievable by picking tworandom numbers between 0 and 1. Define probability of an event as its area

The event of interest is represented by the cross hatched region

6

-

1.0

1.0x

y

Probability of the event is:

area of crosshatched region = 1− 2×1

2(0.75)2 = 0.4375

EE 178/278A: Basic Probability Page 1 – 19

Basic Properties of Probability

• There are several useful properties that can be derived from the axioms ofprobability:

1. P(Ac) = 1− P(A) P(∅) = 0 P(A) ≤ 1

2. If A ⊆ B , then P(A) ≤ P(B)

3. P(A ∪B) = P(A) + P(B)− P(A ∩ B)

4. P(A ∪B) ≤ P(A) + P(B), or in general

P(∪ni=1Ai) ≤

n∑

i=1

P(Ai)

This is called the Union of Events Bound

• These properties can be proved using the axioms of probability and visualizedusing Venn diagrams

EE 178/278A: Basic Probability Page 1 – 20

Page 11: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Conditional Probability

• Conditional probability allows us to compute probabilities of events based onpartial knowledge of the outcome of a random experiment

• Examples:

We are told that the sum of the outcomes from rolling a die twice is 9. Whatis the probability the outcome of the first die was a 6?

A spot shows up on a radar screen. What is the probability that there is anaircraft?

You receive a 0 at the output of a digital communication system. What is theprobability that a 0 was sent?

• As we shall see, conditional probability provides us with two methods forcomputing probabilities of events: the sequential method and thedivide-and-conquer method

• It is also the basis of inference in statistics: make an observation and reasonabout the cause

EE 178/278A: Basic Probability Page 1 – 21

• In general, given an event B has occurred, we wish to find the probability ofanother event A, P(A|B)

• If all elementary outcomes are equally likely, then

P(A|B) =# of outcomes in both A and B

# of outcomes in B

• In general, if B is an event such that P(B) 6= 0, the conditional probability ofany event A given B is defined as

P(A|B) =P(A ∩B)

P(B), or

P(A,B)

P(B)

• The function P(·|B) for fixed B specifies a probability law, i.e., it satisfies theaxioms of probability

EE 178/278A: Basic Probability Page 1 – 22

Page 12: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Example

• Roll a fair four-sided die twice. So, the sample space is 1, 2, 3, 42. All samplepoints have probability 1/16

Let B be the event that the minimum of the two die rolls is 2 and Am, form = 1, 2, 3, 4, be the event that the maximum of the two die rolls is m. FindP(Am|B)

• Solution:

f

f

f

f

f

f

f

f

f

f

f

f

f

f

f

f

f

f

f

f f

2nd roll

1st roll

1

2

3

4

1 2 3 4

-

6

m

P(Am|B)

1 2 3 4

EE 178/278A: Basic Probability Page 1 – 23

Conditional Probability Models

• Before: Probability law ⇒ conditional probabilities

• Reverse is often more natural: Conditional probabilities ⇒ probability law

• We use the chain rule (also called multiplication rule):

By the definition of conditional probability, P(A ∩B) = P(A|B)P(B). Supposethat A1, A2, . . . , An are events, then

EE 178/278A: Basic Probability Page 1 – 24

Page 13: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

P(A1 ∩A2 ∩A3 · · · ∩An)

= P(A1 ∩A2 ∩A3 · · · ∩An−1)× P(An|A1 ∩A2 ∩ A3 · · · ∩An−1)

= P(A1 ∩A2 ∩A3 · · · ∩An−2)× P(An−1|A1 ∩A2 ∩A3 · · · ∩An−2)

× P(An|A1 ∩A2 ∩A3 · · · ∩An−1)

...

= P(A1)× P(A2|A1)× P(A3|A1 ∩A2) · · ·P(An|A1 ∩A2 ∩A3 · · · ∩An−1)

=n∏

i=1

P(Ai|A1, A2, . . . , Ai−1),

where A0 = ∅

EE 178/278A: Basic Probability Page 1 – 25

Sequential Calculation of Probabilities

• Procedure:

1. Construct a tree description of the sample space for a sequential experiment

2. Assign the conditional probabilities on the corresponding branches of the tree

3. By the chain rule, the probability of an outcome can be obtained bymultiplying the conditional probabilities along the path from the root to theleaf node corresponding to the outcome

• Example (Radar Detection): Let A be the event that an aircraft is flying aboveand B be the event that the radar detects it. Assume P(A) = 0.05,P(B|A) = 0.99, and P(B|Ac) = 0.1

What is the probability of

Missed detection?, i.e., P(A ∩ Bc)

False alarm?, i.e., P(B ∩Ac)

The sample space is: Ω = (A,B), (Ac, B), (A,Bc), (Ac, Bc)

EE 178/278A: Basic Probability Page 1 – 26

Page 14: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Solution: Represent the sample space by a tree with conditional probabilities onits edges

P(A) = 0.05

P(B|A) = 0.99

@@@@@@

P(Bc|A) = 0.01

(A,B)

AAAAAAAAAAAA

P(Ac) = 0.95

P(B|Ac) = 0.10

(A,Bc) (Missed detection)

@@@@@@

P(Bc|Ac) = 0.90

(Ac, B) (False alarm)

(Ac, Bc)

EE 178/278A: Basic Probability Page 1 – 27

Example: Three cards are drawn at random (without replacement) from a deckof cards. What is the probability of not drawing a heart?

Solution: Let Ai, i = 1, 2, 3, represent the event of no heart in the ith draw.We can represent the sample space as:

Ω = (A1, A2, A3), (Ac1, A2, A3), . . . , (A

c1, A

c2, A

c3)

To find the probability law, we represent the sample space by a tree, writeconditional probabilities on branches, and use the chain rule

EE 178/278A: Basic Probability Page 1 – 28

Page 15: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

~

P(A1) = 39/52

not heart~

P(A2|A1) = 38/51

(not heart, not heart)~

@@@@@@@

13/51

(not heart, heart)~

AAAAAAAAAAAAAA

P(Ac1) = 13/52

heart~

P(A3|A1, A2) = 37/50 (not heart, not heart, not heart)

HHHHHHH13/50 (not heart, not heart, heart)

~

~

EE 178/278A: Basic Probability Page 1 – 29

Total probability – Divide and Conquer Method

• Let A1, A2, . . . , An be events that partition Ω, i.e., that are disjoint(Ai ∩Aj = ∅ for i 6= j) and ∪n

i=1Ai = Ω. Then for any event B

P(B) =n∑

i=1

P(Ai ∩B) =n∑

i=1

P(Ai)P(B|Ai)

This is called the Law of Total Probability. It also holds for n = ∞. It allows usto compute the probability of a complicated event from knowledge ofprobabilities of simpler events

• Example: Chess tournament, 3 types of opponents for a certain player.

P(Type 1) = 0.5, P(Win |Type1) = 0.3

P(Type 2) = 0.25, P(Win |Type2) = 0.4

P(Type 3) = 0.25, P(Win |Type3) = 0.5

What is probability of player winning?

EE 178/278A: Basic Probability Page 1 – 30

Page 16: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Solution: Let B be the event of winning and Ai be the event of playing Type i,i = 1, 2, 3:

P(B) =3

i=1

P(Ai)P(B|Ai)

= 0.5× 0.3 + 0.25× 0.4 + 0.25× 0.5

= 0.375

EE 178/278A: Basic Probability Page 1 – 31

Bayes Rule

• Let A1, A2, . . . , An be nonzero probability events (the causes) that partition Ω,and let B be a nonzero probability event (the effect)

• We often know the a priori probabilities P(Ai), i = 1, 2, . . . , n and theconditional probabilities P(B|Ai)s and wish to find the a posteriori probabilities

P(Aj|B) for j = 1, 2, . . . , n

• From the definition of conditional probability, we know that

P(Aj|B) =P(B,Aj)

P(B)=

P(B|Aj)

P(B)P(Aj)

By the law of total probability

P(B) =n∑

i=1

P(Ai)P(B|Ai)

EE 178/278A: Basic Probability Page 1 – 32

Page 17: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Substituting we obtain Bayes rule

P(Aj|B) =P(B|Aj)

∑ni=1P(Ai)P(B|Ai)

P(Aj) for j = 1, 2, . . . , n

• Bayes rule also applies when the number of events n = ∞

• Radar Example: Recall that A is event that the aircraft is flying above and B isthe event that the aircraft is detected by the radar. What is the probability thatan aircraft is actually there given that the radar indicates a detection?

Recall P(A) = 0.05, P(B|A) = 0.99, P(B|Ac) = 0.1. Using Bayes rule:

P(there is an aircraft|radar detects it) = P(A|B)

=P(B|A)P(A)

P(B|A)P(A) + P(B|Ac)P(Ac)

=0.05× 0.99

0.05× 0.99 + 0.95× 0.1

= 0.3426

EE 178/278A: Basic Probability Page 1 – 33

Binary Communication Channel

• Consider a noisy binary communication channel, where 0 or 1 is sent and 0 or 1is received. Assume that 0 is sent with probability 0.2 (and 1 is sent withprobability 0.8)

The channel is noisy. If a 0 is sent, a 0 is received with probability 0.9, and if a1 is sent, a 1 is received with probability 0.975

• We can represent this channel model by a probability transition diagram

00

1 1

P(0|0) = 0.9

P(1|1) = 0.975

P(0) = 0.2

P(1) = 0.8

0.1

0.025

Given that 0 is received, find the probability that 0 was sent

EE 178/278A: Basic Probability Page 1 – 34

Page 18: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

• This is a random experiment with sample space Ω = (0, 0), (0, 1), (1, 0), (1, 1),where the first entry is the bit sent and the second is the bit received

• Define the two events

A = 0 is sent = (0, 1), (0, 0), and

B = 0 is received = (0, 0), (1, 0)

• The probability measure is defined via the P(A), P(B|A), and P(Bc|Ac)provided on the probability transition diagram of the channel

• To find P(A|B), the a posteriori probability that a 0 was sent. We use Bayesrule

P(A|B) =P(B|A)P(A)

P(A)P(B|A) + P(Ac)P(B|Ac),

to obtain

P(A|B) =0.9

0.2× 0.2 = 0.9,

which is much higher than the a priori probability of A (= 0.2)

EE 178/278A: Basic Probability Page 1 – 35

Independence

• It often happens that the knowledge that a certain event B has occurred has noeffect on the probability that another event A has occurred, i.e.,

P(A|B) = P(A)

In this case we say that the two events are statistically independent

• Equivalently, two events are said to be statistically independent if

P(A,B) = P(A)P(B)

So, in this case, P(A|B) = P(A) and P(B|A) = P(B)

• Example: Assuming that the binary channel of the previous example is used tosend two bits independently, what is the probability that both bits are in error?

EE 178/278A: Basic Probability Page 1 – 36

Page 19: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Solution:

Define the two events

E1 = First bit is in error

E2 = Second bit is in error

Since the bits are sent independently, the probability that both are in error is

P(E1, E2) = P(E1)P(E2)

Also by symmetry, P(E1) = P(E2)To find P(E1), we express E1 in terms of the events A and B as

E1 = (A1 ∩Bc1) ∪ (Ac

1 ∩B1),

EE 178/278A: Basic Probability Page 1 – 37

Thus,

P(E1) = P(A1, Bc1) + P(Ac

1, B1)

= P(A1)P(Bc1|A1) + P(Ac

1)P(B1|Ac1)

= 0.2× 0.1 + 0.8× 0.025 = 0.04

The probability that the two bits are in error

P(E1, E2) = (0.04)2 = 16× 10−4

• In general A1, A2, . . . , An are mutually independent if for each subset of theevents Ai1, Ai2, . . . , Aik

P(Ai1, Ai2, . . . , Aik) =k∏

j=1

P(Aij)

• Note: P(A1, A2, . . . , An) =∏n

j=1P(Ai) alone is not sufficient for independence

EE 178/278A: Basic Probability Page 1 – 38

Page 20: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Example: Roll two fair dice independently. Define the events

A = First die = 1, 2, or 3

B = First die = 2, 3, or 6

C = Sum of outcomes = 9

Are A, B , and C independent?

EE 178/278A: Basic Probability Page 1 – 39

Solution:

Since the dice are fair and the experiments are performed independently, theprobability of any pair of outcomes is 1/36, and

P(A) =1

2, P(B) =

1

2, P(C) =

1

9

Since A ∩B ∩ C = (3, 6), P(A,B,C) = 136 = P(A)P(B)P(C)

But are A, B , and C independent? Let’s find

P(A,B) =2

6=

1

36=

1

4= P(A)P(B),

and thus A, B , and C are not independent!

EE 178/278A: Basic Probability Page 1 – 40

Page 21: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

• Also, independence of subsets does not necessarily imply independence

Example: Flip a fair coin twice independently. Define the events:

A: First toss is Head

B : Second toss is Head

C : First and second toss have different outcomes

A and B are independent, A and C are independent, and B and C areindependent

Are A,B,C mutually independent?

Clearly not, since if you know A and B , you know that C could not haveoccured, i.e., P(A,B,C) = 0 6= P(A)P(B)P(C) = 1/8

EE 178/278A: Basic Probability Page 1 – 41

Counting

• Discrete uniform law:

Finite sample space where all sample points are equally probable:

P(A) =number of sample points in A

total number of sample points

Variation: all outcomes in A are equally likely, each with probability p. Then,

P(A) = p× (number of elements of A)

• In both cases, we compute probabilities by counting

EE 178/278A: Basic Probability Page 1 – 42

Page 22: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Basic Counting Principle

• Procedure (multiplication rule):

r steps

ni choices at step i

Number of choices is n1 × n2 × · · · × nr

• Example:

Number of license plates with 3 letters followed by 4 digits:

With no repetition (replacement), the number is:

• Example: Consider a set of objects s1, s2, . . . , sn. How many subsets of theseobjects are there (including the set itself and the empty set)?

Each object may or may not be in the subset (2 options)

The number of subsets is:

EE 178/278A: Basic Probability Page 1 – 43

De Mere’s Paradox

• Counting can be very tricky

• Classic example: Throw three 6-sided dice. Is the probability that the sum of theoutcomes is 11 equal to the the probability that the sum of the outcomes is 12?

• De Mere’s argued that they are, since the number of different ways to obtain 11and 12 are the same:

Sum=11: 6, 4, 1, 6, 3, 2, 5, 5, 1, 5, 4, 2, 5, 3, 3, 4, 4, 3

Sum=12: 6, 5, 1, 6, 4, 2, 6, 3, 3, 5, 5, 2, 5, 4, 3, 4, 4, 4

• This turned out to be false. Why?

EE 178/278A: Basic Probability Page 1 – 44

Page 23: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Basic Types of Counting

• Assume we have n distinct objects a1, a2, . . . , an, e.g., digits, letters, etc.

• Some basic counting questions:

How many different ordered sequences of k objects can be formed out of then objects with replacement?

How many different ordered sequences of k ≤ n objects can be formed out ofthe n objects without replacement? (called k-permutations)

How many different unordered sequences (subsets) of k ≤ n objects can beformed out of the n objects without replacement? (called k-combinations)

Given r nonnegative integers n1, n2, . . . , nr that sum to n (the number ofobjects), how many ways can the n objects be partitioned into r subsets(unordered sequences) with the ith subset having exactly ni objects? (callerpartitions, and is a generalization of combinations)

EE 178/278A: Basic Probability Page 1 – 45

Ordered Sequences With and Without Replacement

• The number of ordered k-sequences from n objects with replacement isn× n× n . . .× n k times, i.e., nk

Example: If n = 2, e.g., binary digits, the number of ordered k-sequences is 2k

• The number of different ordered sequences of k objects that can be formed fromn objects without replacement, i.e., the k-permutations, is

n× (n− 1)× (n− 2) · · · × (n− k + 1)

If k = n, the number is

n× (n− 1)× (n− 2) · · · × 2× 1 = n! (n-factorial)

Thus the number of k-permutations is: n!/(n− k)!

• Example: Consider the alphabet set A,B,C,D, so n = 4

The number of k = 2-permutations of n = 4 objects is 12

They are: AB,AC,AD,BA,BC,BD,CA,CB,CD,DA,DB, and DC

EE 178/278A: Basic Probability Page 1 – 46

Page 24: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

Unordered Sequences Without Replacement

• Denote by(

nk

)

(n choose k) the number of unordered k-sequences that can beformed out of n objects without replacement, i.e., the k-combinations

• Two different ways of constructing the k-permutations:

1. Choose k objects ((

nk

)

), then order them (k! possible orders). This gives(

nk

)

× k!

2. Choose the k objects one at a time:

n× (n− 1)× · · · × (n− k + 1) =n!

(n− k)!choices

• Hence(

nk

)

× k! = n!(n−k)! , or

(

nk

)

= n!k!(n−k)!• Example: The number of k = 2-combinations of A,B,C,D is 6

They are AB,AC,AD,BC,BD,CD

• What is the number of binary sequences of length n with exactly k ≤ n ones?

• Question: What is∑n

k=0

(

nk

)

?

EE 178/278A: Basic Probability Page 1 – 47

Finding Probablity Using Counting

• Example: Die Rolling

Roll a fair 6-sided die 6 times independently. Find the probability that outcomesfrom all six rolls are different

Solution:

# outcomes yielding this event =

# of points in sample space =

Probability =

EE 178/278A: Basic Probability Page 1 – 48

Page 25: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

• Example: The Birthday Problem

k people are selected at random. What is the probability that all k birthdayswill be different (neglect leap years)

Solution:

Total # ways of assigning birthdays to k people:

# of ways of assigning birthdays to k people with no two having the samebirthday:

Probability:

EE 178/278A: Basic Probability Page 1 – 49

Binomial Probabilities

• Consider n independent coin tosses, where P(H) = p for 0 < p < 1

• Outcome is a sequence of H s and T s of length n

P(sequence) = p#heads(1− p)#tails

• The probability of k heads in n tosses is thus

P(k heads) =∑

sequences with k heads

P(sequence)

= #(k−head sequences)× pk(1− p)n−k

=

(

n

k

)

pk(1− p)n−k

Check that it sums to 1

EE 178/278A: Basic Probability Page 1 – 50

Page 26: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

• Example: Toss a coin with bias p independently 10 times.

Define the events B = 3 out of 10 tosses are heads andA = first two tosses are heads. Find P(A|B)

Solution: The conditional probability is

P(A|B) =P(A,B)

P(B)

All points in B have the same probability p3(1− p)7, so we can find theconditional probability by counting:

# points in B beginning with two heads =

# points in B =

Probability =

EE 178/278A: Basic Probability Page 1 – 51

Partitions

• Let n1, n2, n3, . . . , nr be such that

r∑

i=1

ni = n

How many ways can the n objects be partitioned into r subsets (unorderedsequences) with the ith subset having exactly ni objects?

• If r = 2 with n1, n− n1 the answer is the n1-combinations( (nn1)

)

• Answer in general:

EE 178/278A: Basic Probability Page 1 – 52

Page 27: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

(

n

n1 n2 . . . nr

)

=

(

n

n1

)

×

(

n− n1

n2

)

×

(

n− (n1 + n2)

n3

)

× . . .

(

n−∑r−1

i=1 ni

nr

)

=n!

n1!(n− n1)!×

(n− n1)!

n2!(n− (n1 + n2))!× · · ·

=n!

n1!n2! · · ·nr!

EE 178/278A: Basic Probability Page 1 – 53

• Example: Balls and bins

We have n balls and r bins. We throw each ball independently and at randominto a bin. What is the probability that bin i = 1, 2, . . . , r will have exactly ni

balls, where∑r

i=1 ni = n?

Solution:

The probability of each outcome (sequence of ni balls in bin i) is:

# of ways of partitioning the n balls into r bins such that bin i has exactlyni balls is:

Probability:

EE 178/278A: Basic Probability Page 1 – 54

Page 28: Lecture Notes 1 Basic Probability - Stanford Universityisl.stanford.edu/~abbas/ee178/lect01-2.pdf · Probability for Continuous Sample Space • Recall that if a sample space is continuous,

• Example: Cards

Consider a perfectly shuffled 52-card deck dealt to 4 players. FindP(each player gets an ace)

Solution:

Size of the sample space is:

# of ways of distributing the four aces:

# of ways of dealing the remaining 48 cards:

Probability =

EE 178/278A: Basic Probability Page 1 – 55