10: The Normal (Gaussian) Distribution

53
10: The Normal (Gaussian) Distribution Lisa Yan April 27, 2020 1

Transcript of 10: The Normal (Gaussian) Distribution

10: The Normal (Gaussian) DistributionLisa Yan

April 27, 2020

1

Lisa Yan, CS109, 2020

Quick slide reference

2

3 Normal RV 10a_normal

15 Normal RV: Properties 10b_normal_props

21 Normal RV: Computing probability 10c_normal_prob

30 Exercises LIVE

Normal RV

3

10a_normal

Lisa Yan, CS109, 2020

Today’s the Big Day

4

Today

Lisa Yan, CS109, 2020

def An Normal random variable 𝑋 is defined as follows:

Other names: Gaussian random variable

Normal Random Variable

5

𝑓 π‘₯ =1

𝜎 2πœ‹π‘’βˆ’ π‘₯βˆ’πœ‡ 2/2𝜎2

𝑋~𝒩(πœ‡, 𝜎2)Support: βˆ’βˆž,∞

Variance

Expectation

PDF

𝐸 𝑋 = πœ‡

Var 𝑋 = 𝜎2

𝑋~𝒩(πœ‡, 𝜎2)mean

variance

π‘₯

𝑓π‘₯

Lisa Yan, CS109, 2020

Carl Friedrich Gauss

Carl Friedrich Gauss (1777-1855) was a remarkably influentialGerman mathematician.

Did not invent Normal distribution but rather popularized it6

Lisa Yan, CS109, 2020

Why the Normal?

β€’ Common for natural phenomena: height, weight, etc.

β€’ Most noise in the world is Normal

β€’ Often results from the sum of many random variables

β€’ Sample means are distributed normally

7

That’s what they

want you to believe…

Lisa Yan, CS109, 2020

Why the Normal?

β€’ Common for natural phenomena: height, weight, etc.

β€’ Most noise in the world is Normal

β€’ Often results from the sum of many random variables

β€’ Sample means are distributed normally

8

Actually log-normal

Just an assumption

Only if equally weighted

(okay this one is true, we’ll see

this in 3 weeks)

Lisa Yan, CS109, 2020

0

0.05

0.1

0.15

0.2

0.25

0 … 44 48 52 56 60 64 … 900 … 44 48 52 56 60 64 … 90

Okay, so why the Normal?

Part of CS109 learning goals:

β€’ Translate a problem statement into a random variable

In other words: model real life situations with probability distributions

9

value

How do you model student heights?

β€’ Suppose you have data from one classroom.

Fits perfectly!

But what about in

another classroom?

Lisa Yan, CS109, 2020

A Gaussian maximizes entropy for a

given mean and variance.

Part of CS109 learning goals:

β€’ Translate a problem statement into a random variable

In other words: model real life situations with probability distributions

0

0.05

0.1

0.15

0.2

0.25

0 … 44 48 52 56 60 64 … 900 … 44 48 52 56 60 64 … 90

Okay, so why the Normal?

10

Occam’s Razor:

β€œNon sunt multiplicanda

entia sine necessitate.”

Entities should not be multiplied

without necessity.

value

How do you model student heights?

β€’ Suppose you have data from one classroom.

β€’ Same mean/var

β€’ Generalizes well

Lisa Yan, CS109, 2020

I encourage you to stay critical of how

to model real-world phenomena.

Why the Normal?

β€’ Common for natural phenomena: height, weight, etc.

β€’ Most noise in the world is Normal

β€’ Often results from the sum of many random variables

β€’ Sample means are distributed normally

11

Actually log-normal

Just an assumption

Only if equally weighted

(okay this one is true, we’ll see

this in 3 weeks)

Lisa Yan, CS109, 2020

Anatomy of a beautiful equation

Let 𝑋~𝒩 πœ‡, 𝜎2 .

The PDF of 𝑋 is defined as:

12

𝑓 π‘₯ =1

𝜎 2πœ‹π‘’βˆ’

π‘₯ βˆ’ πœ‡ 2

2𝜎2

normalizing constantexponential

tail

symmetric

around πœ‡

variance 𝜎2

manages spread

π‘₯

𝑓π‘₯

Lisa Yan, CS109, 2020

Campus bikes

You spend some minutes, 𝑋, travelingbetween classes.

β€’ Average time spent: πœ‡ = 4 minutes

β€’ Variance of time spent: 𝜎2 = 2 minutes2

Suppose 𝑋 is normally distributed. What is the probability you spend β‰₯ 6 minutes traveling?

13

𝑋~𝒩(πœ‡ = 4, 𝜎2 = 2)

𝑃 𝑋 β‰₯ 6 = ΰΆ±6

∞

𝑓(π‘₯)𝑑π‘₯ = ΰΆ±6

∞ 1

𝜎 2πœ‹π‘’βˆ’

π‘₯ βˆ’ πœ‡ 2

2𝜎2 𝑑π‘₯

(call me if you analytically solve this)Loving, not scary…except this time

Lisa Yan, CS109, 2020

Computing probabilities with Normal RVs

For a Normal RV 𝑋~𝒩 πœ‡, 𝜎2 , its CDF has no closed form.

𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ = ΰΆ±βˆ’βˆž

π‘₯ 1

𝜎 2πœ‹π‘’βˆ’

𝑦 βˆ’ πœ‡ 2

2𝜎2 𝑑𝑦

However, we can solve for probabilities numerically using a function Ξ¦:

𝐹 π‘₯ = Ξ¦π‘₯ βˆ’ πœ‡

𝜎

14

Cannot be

solved

analytically

⚠️

CDF of

𝑋~𝒩 πœ‡, 𝜎2A function that has been

solved for numerically

To get here, we’ll first

need to know some

properties of Normal RVs.

Normal RV: Properties

15

10b_normal_props

Lisa Yan, CS109, 2020

Properties of Normal RVs

Let 𝑋~𝒩 πœ‡, 𝜎2 with CDF 𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ .

1. Linear transformations of Normal RVs are also Normal RVs.

If π‘Œ = π‘Žπ‘‹ + 𝑏, then π‘Œ~𝒩(π‘Žπœ‡ + 𝑏, π‘Ž2𝜎2).

2. The PDF of a Normal RV is symmetric about the mean πœ‡.

𝐹 πœ‡ βˆ’ π‘₯ = 1 βˆ’ 𝐹 πœ‡ + π‘₯

16

Lisa Yan, CS109, 2020

1. Linear transformations of Normal RVs

Let 𝑋~𝒩 πœ‡, 𝜎2 with CDF 𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ .

Linear transformations of X are also Normal.

If π‘Œ = π‘Žπ‘‹ + 𝑏, then π‘Œ~𝒩 π‘Žπœ‡ + 𝑏, π‘Ž2𝜎2

Proof:

β€’ 𝐸 π‘Œ = 𝐸 π‘Žπ‘‹ + 𝑏 = π‘ŽπΈ 𝑋 + 𝑏 = π‘Žπœ‡ + 𝑏

β€’ Var π‘Œ = Var π‘Žπ‘‹ + 𝑏 = π‘Ž2Var 𝑋 = π‘Ž2𝜎2

β€’ π‘Œ is also Normal

17

Proof in Ross,

10th ed (Section 5.4)

Linearity of Expectation

Var π‘Žπ‘‹ + 𝑏 = π‘Ž2Var 𝑋

Lisa Yan, CS109, 2020

2. Symmetry of Normal RVs

Let 𝑋~𝒩 πœ‡, 𝜎2 with CDF 𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ .

The PDF of a Normal RV is symmetric about the mean πœ‡.

𝐹 πœ‡ βˆ’ π‘₯ = 1 βˆ’ 𝐹 πœ‡ + π‘₯

18

𝑓(π‘₯)

π‘₯πœ‡

Lisa Yan, CS109, 2020

Using symmetry of the Normal RV

19

1. 𝑃 𝑍 ≀ 𝑧

2. 𝑃 𝑍 < 𝑧

3. 𝑃 𝑍 β‰₯ 𝑧

4. 𝑃 𝑍 ≀ βˆ’π‘§

5. 𝑃 𝑍 β‰₯ βˆ’π‘§

6. 𝑃(𝑦 < 𝑍 < 𝑧) πŸ€”

A. 𝐹 𝑧

B. 1 βˆ’ 𝐹(𝑧)

C. 𝐹 𝑧 βˆ’ 𝐹(𝑦)

= 𝐹 𝑧

𝑧

𝑓(𝑧)

𝐹 πœ‡ βˆ’ π‘₯ = 1 βˆ’ 𝐹 πœ‡ + π‘₯

πœ‡ = 0

Let 𝑍~𝒩 0,1 with CDF 𝑃 𝑍 ≀ 𝑧 = 𝐹 𝑧 .

Suppose we only knew numeric valuesfor 𝐹 𝑧 and 𝐹 𝑦 , for some 𝑧, 𝑦 β‰₯ 0.

How do we compute the following probabilities?

Lisa Yan, CS109, 2020

Using symmetry of the Normal RV

20

1. 𝑃 𝑍 ≀ 𝑧

2. 𝑃 𝑍 < 𝑧

3. 𝑃 𝑍 β‰₯ 𝑧

4. 𝑃 𝑍 ≀ βˆ’π‘§

5. 𝑃 𝑍 β‰₯ βˆ’π‘§

6. 𝑃(𝑦 < 𝑍 < 𝑧)

A. 𝐹 𝑧

B. 1 βˆ’ 𝐹(𝑧)

C. 𝐹 𝑧 βˆ’ 𝐹(𝑦)

= 𝐹 𝑧

= 𝐹 𝑧

= 1 βˆ’ 𝐹(𝑧)

= 1 βˆ’ 𝐹(𝑧)

= 𝐹 𝑧

= 𝐹 𝑧 βˆ’ 𝐹(𝑦)

Symmetry is particularly useful when

computing probabilities of zero-mean

Normal RVs.

𝑧

𝑓(𝑧)

𝐹 πœ‡ βˆ’ π‘₯ = 1 βˆ’ 𝐹 πœ‡ + π‘₯

πœ‡ = 0

Let 𝑍~𝒩 0,1 with CDF 𝑃 𝑍 ≀ 𝑧 = 𝐹 𝑧 .

Suppose we only knew numeric valuesfor 𝐹 𝑧 and 𝐹 𝑦 , for some 𝑧, 𝑦 β‰₯ 0.

How do we compute the following probabilities?

Normal RV:Computing probability

21

10c_normal_probs

Lisa Yan, CS109, 2020

Computing probabilities with Normal RVs

Let 𝑋~𝒩 πœ‡, 𝜎2 .

To compute the CDF, 𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ :

β€’ We cannot analytically solve the integral (it has no closed form)

β€’ …but we can solve numerically using a function Ξ¦:

𝐹 π‘₯ = Ξ¦π‘₯ βˆ’ πœ‡

𝜎

22

CDF of the

Standard Normal, 𝑍

Lisa Yan, CS109, 2020

The Standard Normal random variable 𝑍 is defined as follows:

Other names: Unit Normal

CDF of 𝑍 defined as:

Standard Normal RV, 𝑍

23

𝑍~𝒩(0, 1) Variance

Expectation 𝐸 𝑍 = πœ‡ = 0

Var 𝑍 = 𝜎2 = 1

𝑃 𝑍 ≀ 𝑧 = Ξ¦(𝑧)

Note: not a new distribution; just

a special case of the Normal

Lisa Yan, CS109, 2020

Ξ¦ has been numerically computed

24

𝑃 𝑍 ≀ 1.31 = Ξ¦(1.31)

𝑓𝑧

𝑧

Ξ¦(𝑧)

Standard Normal Table only has

probabilities Ξ¦(𝑧) for 𝑧 β‰₯ 0.

Lisa Yan, CS109, 2020

History fact: Standard Normal Table

25

The first Standard Normal Table was computed by Christian Kramp, French astronomer (1760–1826), in Analysedes RΓ©fractions Astronomiques et Terrestres, 1799

Used a Taylor series expansion to the third power

Lisa Yan, CS109, 2020

Probabilities for a general Normal RV

Let 𝑋~𝒩 πœ‡, 𝜎2 . To compute the CDF 𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ ,we use Ξ¦, the CDF for the Standard Normal 𝑍~𝒩(0, 1):

𝐹 π‘₯ = Ξ¦π‘₯ βˆ’ πœ‡

𝜎Proof:

26

𝐹 π‘₯ = 𝑃 𝑋 ≀ π‘₯

= 𝑃 𝑋 βˆ’ πœ‡ ≀ π‘₯ βˆ’ πœ‡ = 𝑃𝑋 βˆ’ πœ‡

πœŽβ‰€π‘₯ βˆ’ πœ‡

𝜎

= 𝑃 𝑍 ≀π‘₯ βˆ’ πœ‡

𝜎

Algebra + 𝜎 > 0

Definition of CDF

β€’π‘‹βˆ’πœ‡

𝜎=

1

πœŽπ‘‹ βˆ’

πœ‡

𝜎is a linear transform of 𝑋.

β€’ This is distributed as 𝒩1

πœŽπœ‡ βˆ’

πœ‡

𝜎,1

𝜎2𝜎2 =𝒩 0,1

β€’ In other words, π‘‹βˆ’πœ‡

𝜎= 𝑍~𝒩 0,1 with CDF Ξ¦.= Ξ¦

π‘₯ βˆ’ πœ‡

𝜎

Lisa Yan, CS109, 2020

Probabilities for a general Normal RV

Let 𝑋~𝒩 πœ‡, 𝜎2 . To compute the CDF 𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ ,we use Ξ¦, the CDF for the Standard Normal 𝑍~𝒩(0, 1):

𝐹 π‘₯ = Ξ¦π‘₯ βˆ’ πœ‡

𝜎Proof:

27

𝐹 π‘₯ = 𝑃 𝑋 ≀ π‘₯

= 𝑃 𝑋 βˆ’ πœ‡ ≀ π‘₯ βˆ’ πœ‡ = 𝑃𝑋 βˆ’ πœ‡

πœŽβ‰€π‘₯ βˆ’ πœ‡

𝜎

= 𝑃 𝑍 ≀π‘₯ βˆ’ πœ‡

𝜎

Algebra + 𝜎 > 0

Definition of CDF

β€’π‘‹βˆ’πœ‡

𝜎=

1

πœŽπ‘‹ βˆ’

πœ‡

𝜎is a linear transform of 𝑋.

β€’ This is distributed as 𝒩1

πœŽπœ‡ βˆ’

πœ‡

𝜎,1

𝜎2𝜎2 =𝒩 0,1

β€’ In other words, π‘‹βˆ’πœ‡

𝜎= 𝑍~𝒩 0,1 with CDF Ξ¦.= Ξ¦

π‘₯ βˆ’ πœ‡

𝜎

1. Compute 𝑧 = π‘₯ βˆ’ πœ‡ /𝜎.

2. Look up Ξ¦ 𝑧 in Standard Normal table.

Lisa Yan, CS109, 2020

Campus bikes

You spend some minutes, 𝑋, traveling between classes.β€’ Average time spent: πœ‡ = 4 minutesβ€’ Variance of time spent: 𝜎2 = 2 minutes2

Suppose 𝑋 is normally distributed. What is the probability you spend β‰₯ 6 minutes traveling?

28

𝑋~𝒩(πœ‡ = 4, 𝜎2 = 2) 𝑃 𝑋 β‰₯ 6 = ΰΆ±6

∞

𝑓(π‘₯)𝑑π‘₯ (no analytic solution)

1. Compute 𝑧 =π‘₯βˆ’πœ‡

𝜎2. Look up Ξ¦(𝑧) in table

𝑃 𝑋 β‰₯ 6 = 1 βˆ’ 𝐹π‘₯(6)

= 1 βˆ’ Ξ¦6 βˆ’ 4

2

Γ—

β‰ˆ 1 βˆ’ Ξ¦ 1.41

1 βˆ’ Ξ¦ 1.41β‰ˆ 1 βˆ’ 0.9207= 0.0793

Lisa Yan, CS109, 2020

Is there an easier way? (yes)

Let 𝑋~𝒩 πœ‡, 𝜎2 . What is 𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ ?

β€’ Use Python

β€’ Use website tool

29

from scipy import statsX = stats.norm(mu, std)X.cdf(x)

SciPy reference:https://docs.scipy.org/doc/scipy/refere

nce/generated/scipy.stats.norm.html

Website tool: https://web.stanford.edu/class/cs109

/handouts/normalCDF.html

(live)10: The Normal (Gaussian) DistributionLisa Yan

July 13, 2020

30

Lisa Yan, CS109, 2020

The Normal (Gaussian) Random Variable

Let 𝑋~𝒩 πœ‡, 𝜎2 .

The PDF of 𝑋 is defined as:

31

𝑓 π‘₯ =1

𝜎 2πœ‹π‘’βˆ’

π‘₯ βˆ’ πœ‡ 2

2𝜎2

normalizing constantexponential

tail

symmetric

around πœ‡

variance 𝜎2

manages spread

π‘₯

𝑓π‘₯

Review

ThinkSlide 34 has a question to go over by yourself.

Post any clarifications here!

https://us.edstem.org/courses/667/discussion/89934

Think by yourself: 2 min

32

πŸ€”(by yourself)

Lisa Yan, CS109, 2020

Normal Random Variable

Match PDF to distribution:

𝒩 0, 1

𝒩(βˆ’2, 0.5)

𝒩 0, 5

𝒩(0, 0.2)

33

A.

B.

C.

D.

𝑋~𝒩(πœ‡, 𝜎2)mean variance

πŸ€”(by yourself)

π‘₯

𝑓π‘₯

Lisa Yan, CS109, 2020

Knowing how to use a Standard Normal Table will

still be useful in our understanding of Normal RVs.

Computing probabilities with Normal RVs: Old school

34

*particularly useful if we had closed book exams with no calculator**

**we have open book exams with calculators this quarter

Ξ¦ 𝑧 for non-negative 𝑧

*

Lisa Yan, CS109, 2020

Computing probabilities with Normal RVs

Let 𝑋~𝒩 πœ‡, 𝜎2 . What is 𝑃 𝑋 ≀ π‘₯ = 𝐹 π‘₯ ?

1. Rewrite in terms of standard normal CDF Ξ¦ by computing 𝑧 =π‘₯βˆ’πœ‡

𝜎.

Linear transforms of Normals are Normal:

𝐹 π‘₯ = Ξ¦π‘₯ βˆ’ πœ‡

𝜎

2. Then, look up in a Standard Normal Table, where 𝑧 β‰₯ 0.

Normal PDFs are symmetric about their mean:

Ξ¦ βˆ’π‘§ = 1 βˆ’ Ξ¦ 𝑧

35

Review

𝑍 =π‘‹βˆ’πœ‡

𝜎, where 𝑍~ 𝒩 0,1

Lisa Yan, CS109, 2020

Get your Gaussian On

Let 𝑋~𝒩 πœ‡ = 3, 𝜎2 = 16 . Std deviation 𝜎 = 4.

1. 𝑃 𝑋 > 0

36

β€’ If 𝑋~𝒩 πœ‡, 𝜎2 , then

𝐹 π‘₯ = Ξ¦π‘₯βˆ’πœ‡

𝜎

β€’ Symmetry of the PDF of

Normal RV implies

Ξ¦ βˆ’π‘§ = 1 βˆ’ Ξ¦ 𝑧

Breakout Rooms

Slide 39 has two questions to go over in groups.

Post any clarifications here!

https://us.edstem.org/courses/667/discussion/89934

Breakout rooms: 5 mins

37

πŸ€”

Lisa Yan, CS109, 2020

Get your Gaussian On

Let 𝑋~𝒩 πœ‡ = 3, 𝜎2 = 16 .Note standard deviation 𝜎 = 4.

How would you write each of the belowprobabilities as a function of thestandard normal CDF, Ξ¦?

1. 𝑃 𝑋 > 0 (we just did this)

2. 𝑃 2 < 𝑋 < 5

3. 𝑃 𝑋 βˆ’ 3 > 6

38

β€’ If 𝑋~𝒩 πœ‡, 𝜎2 , then

𝐹 π‘₯ = Ξ¦π‘₯βˆ’πœ‡

𝜎

β€’ Symmetry of the PDF of

Normal RV implies

Ξ¦ βˆ’π‘§ = 1 βˆ’ Ξ¦ 𝑧

πŸ€”

Lisa Yan, CS109, 2020

Get your Gaussian On

Let 𝑋~𝒩 πœ‡ = 3, 𝜎2 = 16 . Std deviation 𝜎 = 4.

1. 𝑃 𝑋 > 0

2. 𝑃 2 < 𝑋 < 5

39

β€’ If 𝑋~𝒩 πœ‡, 𝜎2 , then

𝐹 π‘₯ = Ξ¦π‘₯βˆ’πœ‡

𝜎

β€’ Symmetry of the PDF of

Normal RV implies

Ξ¦ βˆ’π‘§ = 1 βˆ’ Ξ¦ 𝑧

Lisa Yan, CS109, 2020

Get your Gaussian On

Let 𝑋~𝒩 πœ‡ = 3, 𝜎2 = 16 . Std deviation 𝜎 = 4.

1. 𝑃 𝑋 > 0

2. 𝑃 2 < 𝑋 < 5

3. 𝑃 𝑋 βˆ’ 3 > 6

40

Compute 𝑧 =π‘₯βˆ’πœ‡

𝜎

β€’ If 𝑋~𝒩 πœ‡, 𝜎2 , then

𝐹 π‘₯ = Ξ¦π‘₯βˆ’πœ‡

𝜎

β€’ Symmetry of the PDF of

Normal RV implies

Ξ¦ βˆ’π‘₯ = 1 βˆ’ Ξ¦ π‘₯

𝑃 𝑋 < βˆ’3 + 𝑃 𝑋 > 9

= 𝐹 βˆ’3 + 1 βˆ’ 𝐹 9

= Ξ¦βˆ’3 βˆ’ 3

4+ 1 βˆ’Ξ¦

9 βˆ’ 3

4

Look up Ξ¦(z) in table

Lisa Yan, CS109, 2020

Get your Gaussian On

Let 𝑋~𝒩 πœ‡ = 3, 𝜎2 = 16 . Std deviation 𝜎 = 4.

1. 𝑃 𝑋 > 0

2. 𝑃 2 < 𝑋 < 5

3. 𝑃 𝑋 βˆ’ 3 > 6

41

Compute z =π‘₯βˆ’πœ‡

𝜎Look up Φ(z) in table

𝑃 𝑋 < βˆ’3 + 𝑃 𝑋 > 9

= 𝐹 βˆ’3 + 1 βˆ’ 𝐹 9

= Ξ¦βˆ’3 βˆ’ 3

4+ 1 βˆ’Ξ¦

9 βˆ’ 3

4

= Ξ¦ βˆ’3

2+ 1 βˆ’Ξ¦

3

2

= 2 1 βˆ’ Ξ¦3

2

β‰ˆ 0.1337

β€’ If 𝑋~𝒩 πœ‡, 𝜎2 , then

𝐹 π‘₯ = Ξ¦π‘₯βˆ’πœ‡

𝜎

β€’ Symmetry of the PDF of

Normal RV implies

Ξ¦ βˆ’π‘₯ = 1 βˆ’ Ξ¦ π‘₯

Interlude for jokes/announcements

42

Lisa Yan, CS109, 2020

Announcements

43

Problem Set 3

Due: Friday 7/13 1pm PT

Tim’s OH permanently moved to 8-10pm PT, Wednesday

Lisa Yan, CS109, 2020

Interesting probability news

44

https://www.forbes.com/sites/lanceeliot/2020/04/12/on-

the-probabilities-of-social-distancing-as-gleaned-from-ai-self-

driving-cars/#218da4489472

Breakout Rooms

Slide 47 has two questions to go over in groups.

Post any clarifications here!

https://us.edstem.org/courses/667/discussion/89934

Breakout rooms: 5 mins

45

πŸ€”

Lisa Yan, CS109, 2020

Noisy Wires

Send a voltage of 2 V or βˆ’2 V onwire (to denote 1 and 0, respectively).

β€’ 𝑋 = voltage sent (2 or βˆ’2)β€’ π‘Œ = noise, π‘Œ~𝒩 0, 1β€’ 𝑅 = 𝑋 + π‘Œ voltage received.

Decode: 1 if 𝑅 β‰₯ 0.50 otherwise.

1. What is P(decoding error | original bit is 1)?i.e., we sent 1, but we decoded as 0?

2. What is P(decoding error | original bit is 0)?

These probabilities are unequal. Why might this be useful?46

πŸ€”πΉπ‘…(π‘Ÿ)

𝑅 = π‘Ÿ

Lisa Yan, CS109, 2020

Noisy Wires

Send a voltage of 2 V or βˆ’2 V onwire (to denote 1 and 0, respectively).

β€’ 𝑋 = voltage sent (2 or βˆ’2)β€’ π‘Œ = noise, π‘Œ~𝒩 0, 1β€’ 𝑅 = 𝑋 + π‘Œ voltage received.

Decode: 1 if 𝑅 β‰₯ 0.50 otherwise.

1. What is P(decoding error | original bit is 1)?i.e., we sent 1, but we decoded as 0?

47𝐹𝑅(π‘Ÿ)

𝑅 = π‘Ÿ

𝑃 𝑅 < 0.5| 𝑋 = 2 = 𝑃 2 + π‘Œ < 0.5 = 𝑃 π‘Œ < βˆ’1.5 Y is Standard Normal

= Ξ¦ βˆ’1.5 = 1 βˆ’ Ξ¦ 1.5 β‰ˆ 0.0668

Lisa Yan, CS109, 2020

Noisy Wires

Send a voltage of 2 V or βˆ’2 V onwire (to denote 1 and 0, respectively).

β€’ 𝑋 = voltage sent (2 or βˆ’2)β€’ π‘Œ = noise, π‘Œ~𝒩 0, 1β€’ 𝑅 = 𝑋 + π‘Œ voltage received.

Decode: 1 if 𝑅 β‰₯ 0.50 otherwise.

1. What is P(decoding error | original bit is 1)?i.e., we sent 1, but we decoded as 0?

2. What is P(decoding error | original bit is 0)?

48𝐹𝑅(π‘Ÿ)

𝑅 = π‘Ÿ

0.0668

β‰ˆ 0.0062𝑃 𝑅 β‰₯ 0.5| 𝑋 = βˆ’2 = 𝑃 βˆ’2 + π‘Œ β‰₯ 0.5 = 𝑃 π‘Œ β‰₯ 2.5Asymmetric decoding probability: We would like to avoid

mistaking a 0 for 1. Errors the other way are more tolerable.

Challenge: Sampling with the Normal RV

49

LIVE

Lisa Yan, CS109, 2020

ELO ratings

50

What is the probability that the Warriors win?

How do you model zero-sum games?

Lisa Yan, CS109, 2020

ELO ratings

Each team has an ELO score 𝑆, calculated based on theirpast performance.

β€’ Each game, a team hasability 𝐴~𝒩 𝑆, 2002 .

β€’ The team with the highersampled ability wins.

What is the probabilitythat Warriors winthis game?

Want: 𝑃 Warriors win = 𝑃 π΄π‘Š > 𝐴𝐡

51

0

0.0005

0.001

0.0015

0.002

0.0025

1000 1500 2000 2500

πœ‡=1470

0

0.0005

0.001

0.0015

0.002

0.0025

1000 1500 2000 2500

πœ‡=1657

Arpad Elo

Warriors π΄π‘Š~𝒩 𝑆 = 1657, 2002

Opponents 𝐴𝐡~𝒩 𝑆 = 1470, 2002

Lisa Yan, CS109, 2020

ELO ratings

52

Want: 𝑃 Warriors win = 𝑃 π΄π‘Š > 𝐴𝐡

β‰ˆ 0.7488, calculated by sampling

from scipy import statsWARRIORS_ELO = 1657OPPONENT_ELO = 1470STDEV = 200NTRIALS = 10000

nSuccess = 0for i in range(NTRIALS):w = stats.norm.rvs(WARRIORS_ELO, STDEV)b = stats.norm.rvs(OPPONENT_ELO, STDEV)if w > b:nSuccess += 1

print("Warriors sampled win fraction", float(nSuccess) /NTRIALS)

Lisa Yan, CS109, 2020

Is there a better way?

𝑃 π΄π‘Š > 𝐴𝐡

β€’ This is a probability of an event involving two random variables!

β€’ We’ll solve this problem analytically in upcoming weeks.

Big goal for next time: Events involving two discrete random variables.Stay tuned!

53