cse 312 foundations of computing ii...slide credit: based on stefano tessaro’sslides for 312 19au...

25
CSE 312 Foundations of Computing II Lecture 17: Normal Distribution & Central Limit Theorem 1 Slide Credit: Based on Stefano Tessaro’s slides for 312 19au incorporating ideas from Alex Tsun’s and Anna Karlin’s slides for 312 20su and 20au Rachel Lin, Hunter Schafer

Upload: others

Post on 26-Mar-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

CSE 312

Foundations of Computing II

Lecture 17: Normal Distribution & Central Limit Theorem

1

Slide Credit: Based on Stefano Tessaro’s slides for 312 19au

incorporating ideas from Alex Tsun’s and Anna Karlin’s slides for 312 20su and 20au

Rachel Lin, Hunter Schafer

Page 2: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Review – Continuous RVs

2

Probability Density Function (PDF).

𝑓:ℝ → ℝ s.t.

• 𝑓 𝑥 ≥ 0 for all 𝑥 ∈ ℝ

• ∞−+∞

𝑓 𝑥 d𝑥 = 1

Cumulative Density Function (CDF).

𝐹 𝑦 = න−∞

𝑦

𝑓(𝑥) d𝑥

Theorem. 𝑓 𝑥 =𝑑𝐹(𝑥)

𝑑𝑥

𝑓(𝑥)

= 1

𝐹(𝑦)

𝑦

Density ≠ Probability ! 𝐹 𝑦 = ℙ 𝑋 ≤ 𝑦

Page 3: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Review – Continuous RVs

3

𝑓𝑋(𝑥)

𝑎 𝑏

ℙ 𝑋 ∈ [𝑎, 𝑏] = න𝑎

𝑏

𝑓𝑋 𝑥 d𝑥 = 𝐹𝑋 𝑏 − 𝐹𝑋(𝑎)

Page 4: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Exponential Distribution

Definition. An exponential random variable 𝑋 with parameter 𝜆 ≥ 0 is follows the exponential density

𝑓𝑋 𝑥 = ቊ𝜆𝑒−𝜆𝑥 𝑥 ≥ 00 𝑥 < 0

CDF: For 𝑦 ≥ 0,𝐹𝑋 𝑦 = 1 − 𝑒−𝜆𝑦

We write 𝑋 ∼ Exp 𝜆 and say 𝑋 that follows the exponential distribution.

0

0.5

1

1.5

2

0 1 2 3 4 5 6 7

𝜆 = 2

𝜆 = 1.5

𝜆 = 1

𝜆 = 0.5

Page 5: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Agenda

• Normal Distribution

• Practice with Normals

• Central Limit Theorem (CLT)

5

Page 6: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

The Normal Distribution

6

Definition. A Gaussian (or normal) random variable with parameters 𝜇 ∈ ℝ and 𝜎 ≥ 0 has density

𝑓𝑋 𝑥 =1

2𝜋𝜎𝑒−

𝑥−𝜇 2

2𝜎2

(We say that 𝑋 follows the Normal Distribution, and write 𝑋 ∼ 𝒩(𝜇, 𝜎2))

Fact. If 𝑋 ∼ 𝒩 𝜇, 𝜎2 , then 𝔼 𝑋 = 𝜇, and Var 𝑋 = 𝜎2

Proof is easy because density curve is symmetric around 𝜇, 𝑓𝑋 𝜇 − 𝑥 = 𝑓𝑋(𝜇 + 𝑥)

Page 7: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

The Normal Distribution

7

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

-18 -15 -12 -9 -6 -3 0 3 6 9 12 15 18

𝜇 = 0, 𝜎2 = 3

𝜇 = 0,𝜎2 = 8

𝜇 = −7,𝜎2 = 6

𝜇 = 7,𝜎2 = 1

Aka a “Bell Curve” (imprecise name)

Page 8: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Shifting and Scaling – turning one normal dist into another

Fact. If 𝑋 ∼ 𝒩 𝜇, 𝜎2 , then 𝑌 = 𝑎𝑋 + 𝑏 ∼ 𝒩 𝑎𝜇 + 𝑏, 𝑎2𝜎2

8

𝔼 𝑌 = 𝑎 𝔼 𝑋 + 𝑏 = 𝑎𝜇 + 𝑏

Var 𝑌 = 𝑎2 Var 𝑋 = 𝑎2𝜎2

Proof.

Can show with algebra that the PDF of 𝑌 = 𝑎𝑋 + 𝑏 is still normal.

Page 9: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

CDF of normal distribution

9

Standard (unit) normal = 𝒩 0, 1

CDF. Φ 𝑧 = ℙ 𝑍 ≤ 𝑧 =1

2𝜋∞−𝑧𝑒−𝑥

2/2d𝑥 for 𝑍 ∼ 𝒩 0, 1

Note: Φ 𝑧 has no closed form – generally given via tables

Fact. If 𝑋 ∼ 𝒩 𝜇, 𝜎2 , then 𝑌 = 𝑎𝑋 + 𝑏 ∼ 𝒩 𝑎𝜇 + 𝑏, 𝑎2𝜎2

Page 10: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Table of Standard Cumulative Normal Density

10

ℙ 𝑍 ≤ 1.09

ℙ 𝑍 ≤ −1.09 ?What is

Poll: pollev.com/hunter312a. 0.1379b. 0.8621c. 0d. Not able to compute

= Φ 1.09 ≈ 0.8621

Page 11: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Closure of the normal -- under addition

Fact. If 𝑋 ∼ 𝒩 𝜇𝑋, 𝜎𝑋2 , Y ∼ 𝒩 𝜇𝑌, 𝜎𝑌

2 (both independent normal RV)

then a𝑋 + 𝑏𝑌 + 𝑐 ∼ 𝒩 𝑎𝜇𝑋 + 𝑏𝜇𝑌 + 𝑐, 𝑎2𝜎𝑋2 + 𝑏2𝜎𝑌

2

Note: The special thing is that the sum of normal RVs is still a normal RV.

The values of the expectation and variance is not surprising. Why?• Linearity of expectation (always true) • When 𝑋 and 𝑌 are independent, 𝑉𝑎𝑟 𝑎𝑋 + 𝑏𝑌 = 𝑎2𝑉𝑎𝑟 𝑋 + 𝑏2𝑉𝑎𝑟(𝑌)

Page 12: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Brain Break

Normal Distribution Paranormal Distribution

Page 13: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Agenda

• Normal Distribution

• Practice with Normals

• Central Limit Theorem (CLT)

13

Page 14: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

What about Non-standard normal?

14

If 𝑋 ∼ 𝒩 𝜇, 𝜎2 , then 𝑋 −𝜇

𝜎∼ 𝒩(0, 1)

Therefore,

𝐹𝑋 𝑧 = ℙ 𝑋 ≤ 𝑧 = ℙ𝑋 − 𝜇

𝜎≤𝑧 − 𝜇

𝜎= Φ

𝑧 − 𝜇

𝜎

Page 15: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Example

Let 𝑋 ∼ 𝒩 0.4, 4 = 22 .

15

ℙ 𝑋 ≤ 1.2 = ℙ𝑋 − 0.4

2≤1.2 − 0.4

2

= ℙ𝑋 − 0.4

2≤ 0.4

∼ 𝒩 0, 1

= Φ(0.4) ≈ 0.6554

Page 16: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Example

Let 𝑋 ∼ 𝒩 3, 16 .

16

ℙ 2 < 𝑋 < 5 = ℙ2 − 3

4<𝑋 − 3

4<5 − 3

4

= ℙ −1

4< 𝑍 <

1

2

= Φ1

2− Φ −

1

4

≈ 0.29017= Φ1

2− 1 − Φ

1

4

Page 17: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Example – Off by Standard Deviations

17

Let 𝑋 ∼ 𝒩 𝜇, 𝜎2 .

ℙ 𝑋 − 𝜇 < 𝑘𝜎 = ℙ𝑋 − 𝜇

𝜎< 𝑘 =

= ℙ −𝑘 <𝑋 − 𝜇

𝜎< 𝑘 = Φ 𝑘 −Φ(−𝑘)

e.g. 𝑘 = 1: 68%, 𝑘 = 2: 95%, 𝑘 = 3: 99%

Page 18: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Agenda

• Normal Distribution

• Practice with Normals

• Central Limit Theorem (CLT)

18

Page 19: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Gaussian in Nature

Empirical distribution of collected data often resembles a Gaussian …

19

e.g. Height distribution resembles Gaussian.

R.A.Fisher (1918) observed that the height is likely the outcome of the sum of many independent random parameters, i.e., can written as

𝑋 = 𝑋1 +⋯+ 𝑋𝑛

Page 20: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Sum of Independent RVs

20

𝑋1, … , 𝑋𝑛 i.i.d. with expectation 𝜇 and variance 𝜎2

i.i.d. = independent and identically distributed

Define

𝑆𝑛 = 𝑋1 +⋯+ 𝑋𝑛

𝔼 𝑆𝑛 =

Var(𝑆𝑛) =

𝔼 𝑋1 +⋯+ 𝔼 𝑋𝑛 = 𝑛𝜇

Var 𝑋1 +⋯+ Var 𝑋𝑛 = 𝑛𝜎2

Empirical observation: 𝑆𝑛 looks like a normal RV as 𝑛 grows.

Page 21: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

CLT (Idea)

21From: https://courses.cs.washington.edu/courses/cse312/17wi/slides/10limits.pdf

Page 22: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

CLT (Idea)

22From: https://courses.cs.washington.edu/courses/cse312/17wi/slides/10limits.pdf

Page 23: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Central Limit Theorem

23

𝑋1, … , 𝑋𝑛 i.i.d., each with expectation 𝜇 and variance 𝜎2

Define 𝑆𝑛 = 𝑋1 +⋯+ 𝑋𝑛 and

𝑌𝑛 =𝑆𝑛 − 𝑛𝜇

𝜎 𝑛

𝔼 𝑌𝑛 =

Var(𝑌𝑛) =

1

𝜎 𝑛𝔼(𝑆𝑛) − 𝑛𝜇 =

1

𝜎 𝑛𝑛𝜇 − 𝑛𝜇 = 0

1

𝜎2𝑛Var 𝑆𝑛 − 𝑛𝜇 =

Var(𝑆𝑛)

𝜎2𝑛=𝜎2𝑛

𝜎2𝑛= 1

Page 24: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

Central Limit Theorem

24

Theorem. (Central Limit Theorem) The CDF of 𝑌𝑛 converges to the CDF of the standard normal 𝒩(0,1), i.e.,

lim𝑛→∞

ℙ 𝑌𝑛 ≤ 𝑦 =1

2𝜋න−∞

𝑦

𝑒−𝑥2/2d𝑥

𝑌𝑛 =𝑋1 +⋯+ 𝑋𝑛 − 𝑛𝜇

𝜎 𝑛

Page 25: CSE 312 Foundations of Computing II...Slide Credit: Based on Stefano Tessaro’sslides for 312 19au incorporating ideas from Alex Tsun’sand Anna Karlin’sslides for 312 20su and

CLT → Normal Distribution EVERYWHERE

25

Neuron Activity

S&P 500 Returns after Elections

Vegetables

Examples from: https://galtonboard.com/probabilityexamplesinlife