Probability and Statistics for Computer Science All - - PowerPoint PPT Presentation

probability and statistics
SMART_READER_LITE
LIVE PREVIEW

Probability and Statistics for Computer Science All - - PowerPoint PPT Presentation

Probability and Statistics for Computer Science All models are wrong, but some models are useful--- George Box Credit:


slide-1
SLIDE 1

ì ¡

Probability ¡and ¡Statistics ¡ for ¡Computer ¡Science ¡ ¡

“All ¡models ¡are ¡wrong, ¡but ¡some ¡ models ¡are ¡useful”-­‑-­‑-­‑ ¡George ¡Box ¡ ¡ ¡

Hongye ¡Liu, ¡Teaching ¡Assistant ¡Prof, ¡CS361, ¡UIUC, ¡12.10.2019 ¡ Credit: ¡wikipedia ¡

slide-2
SLIDE 2

Last ¡time ¡

✺ Linear ¡regression ¡(cont.) ¡

✺ Modeling ¡non-­‑linear ¡relaRonship ¡with ¡linear ¡

regression ¡

✺ Outliers ¡and ¡over-­‑fiVng ¡issues ¡ ✺ Regularized ¡linear ¡regression/Ridge ¡regression ¡

✺ Nearest ¡neighbor ¡regression ¡

¡

slide-3
SLIDE 3

What ¡if ¡the ¡relationship ¡between ¡variables ¡ is ¡non-­‑linear? ¡

✺ A ¡linear ¡model ¡will ¡

not ¡produce ¡a ¡good ¡ fit ¡if ¡the ¡dependent ¡ variable ¡is ¡not ¡linear ¡ combinaRon ¡of ¡the ¡ explanatory ¡variables ¡ ¡ ¡ ¡ ¡

R2 ¡= ¡0.1 ¡

slide-4
SLIDE 4

Transforming ¡variables ¡could ¡allow ¡linear ¡ model ¡to ¡model ¡non-­‑linear ¡relationship ¡

✺ In ¡the ¡word-­‑ ¡frequency ¡

example, ¡log-­‑transforming ¡ both ¡variables ¡would ¡ allow ¡a ¡linear ¡model ¡to ¡fit ¡ the ¡data ¡well. ¡ ¡

¡ ¡

slide-5
SLIDE 5

More ¡example: ¡Data ¡of ¡fish ¡in ¡a ¡Finland ¡ lake ¡

Yellow ¡Perch ¡

✺ Perch ¡(a ¡kind ¡of ¡fish) ¡in ¡a ¡

lake ¡in ¡Finland, ¡56 ¡data ¡

  • bservaRons ¡ ¡

✺ Variables ¡include: ¡Weight, ¡

Length, ¡Height, ¡Width ¡

✺ In ¡order ¡to ¡illustrate ¡the ¡

point, ¡let’s ¡model ¡Weight ¡ as ¡the ¡dependent ¡variable ¡ and ¡the ¡Length ¡as ¡the ¡ explanatory ¡variable. ¡

¡

slide-6
SLIDE 6

Is ¡the ¡linear ¡model ¡fine ¡for ¡this ¡data? ¡

✺ R-­‑squared ¡is ¡0.87 ¡may ¡

suggest ¡the ¡model ¡is ¡ OK ¡

✺ But ¡the ¡trend ¡of ¡the ¡

data ¡suggests ¡non-­‑ linear ¡relaRonship ¡

✺ IntuiRon ¡tells ¡us ¡length ¡

is ¡not ¡linear ¡to ¡weight ¡ given ¡fish ¡is ¡3-­‑ dimensional ¡

✺ We ¡can ¡do ¡befer! ¡

slide-7
SLIDE 7

Transforming ¡the ¡explanatory ¡variables ¡

slide-8
SLIDE 8
  • Q. ¡What ¡are ¡the ¡matrix ¡X ¡and ¡ ¡y? ¡

Length3 ¡ Weight ¡ 1 ¡

slide-9
SLIDE 9

Contents ¡

✺ Markov ¡chain ¡ ✺ MoRvaRon ¡ ✺ DefiniRon ¡of ¡Markov ¡model ¡ ✺ Graph ¡representaRon ¡– ¡Markov ¡chain ¡ ✺ TransiRon ¡probability ¡matrix ¡ ✺ The ¡staRonary ¡Markov ¡chain ¡ ✺ The ¡pageRank ¡algorithm ¡

¡

slide-10
SLIDE 10

Motivation ¡

✺ So ¡far, ¡the ¡processes ¡we ¡learned ¡such ¡as ¡

Bernoulli ¡and ¡Poisson ¡process ¡are ¡sequences ¡

  • f ¡independent ¡trials. ¡

✺ There ¡are ¡a ¡lot ¡of ¡real ¡world ¡situaRons ¡where ¡

sequences ¡of ¡events ¡are ¡Not ¡independent ¡In ¡

  • comparison. ¡

✺ Markov ¡chain ¡is ¡one ¡type ¡of ¡characterizaRon ¡

  • f ¡a ¡series ¡of ¡dependent ¡trials. ¡
slide-11
SLIDE 11

An ¡example ¡of ¡dependent ¡events ¡in ¡a ¡ sequence ¡

I ¡had ¡a ¡glass ¡of ¡wine ¡with ¡my ¡grilled ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

slide-12
SLIDE 12

An ¡example ¡of ¡dependent ¡events ¡in ¡a ¡ sequence ¡

slide-13
SLIDE 13

An ¡example ¡of ¡dependent ¡events ¡in ¡a ¡ sequence ¡

slide-14
SLIDE 14

Markov ¡chain ¡

✺ Markov ¡chain ¡is ¡a ¡process ¡

in ¡which ¡outcome ¡of ¡any ¡ trial ¡in ¡a ¡sequence ¡is ¡ condi6oned ¡by ¡the ¡

  • utcome ¡of ¡the ¡trial ¡

immediately ¡preceding, ¡but ¡ not ¡by ¡earlier ¡ones. ¡ ¡

✺ Such ¡dependence ¡is ¡called ¡

chain ¡dependence ¡

¡

Andrey ¡Markov ¡(1856-­‑1922) ¡

slide-15
SLIDE 15

Markov ¡chain ¡in ¡terms ¡of ¡probability ¡

✺ Let ¡ ¡ ¡ ¡ ¡ ¡, ¡ ¡ ¡ ¡ ¡ ¡,… ¡be ¡a ¡sequence ¡of ¡discrete ¡finite-­‑valued ¡

random ¡variables ¡ ¡

✺ The ¡sequence ¡is ¡a ¡Markov ¡chain ¡if ¡the ¡probability ¡

distribuRon ¡ ¡ ¡ ¡ ¡ ¡only ¡depends ¡on ¡the ¡distribuRon ¡of ¡the ¡ immediately ¡preceding ¡random ¡variable ¡

✺ If ¡the ¡condiRonal ¡probabiliRes ¡(transiRon ¡probabiliRes) ¡

do ¡NOT ¡change ¡with ¡6me, ¡it’s ¡called ¡constant ¡Markov ¡

  • chain. ¡

P(Xt|X0..., Xt−1) = P(Xt|Xt−1)

P(Xt|Xt−1) = P(Xt−1|Xt−2) = ... = P(X1|X0) X0 X1 Xt Xt−1

slide-16
SLIDE 16

Coin ¡example ¡

✺ Toss ¡a ¡fair ¡coin ¡unRl ¡you ¡see ¡two ¡heads ¡in ¡a ¡row ¡and ¡

then ¡stop, ¡what ¡is ¡the ¡probability ¡of ¡stopping ¡aker ¡ exactly ¡n ¡flips? ¡ ¡

✺ Use ¡a ¡state ¡diagram, ¡which ¡is ¡a ¡directed ¡graph. ¡Circles ¡

are ¡the ¡states ¡of ¡likely ¡outcomes. ¡Arrow ¡direcRons ¡show ¡the ¡ direcRon ¡of ¡transiRons. ¡Numbers ¡over ¡the ¡arrows ¡show ¡ transiRon ¡probabiliRes. ¡ ¡ ¡

3 ¡ 1 ¡-­‑> ¡Start ¡or ¡just ¡had ¡tail/restart ¡ 2 ¡-­‑> ¡had ¡one ¡head ¡aJer ¡start/restart ¡ 3 ¡-­‑> ¡2heads ¡in ¡a ¡row/Stop ¡ 1/2 ¡ 1/2 ¡ 1/2 ¡ 1/2 ¡

slide-17
SLIDE 17

Is ¡this ¡a ¡Markov ¡chain? ¡And ¡why? ¡

3 ¡ 1/2 ¡ 1/2 ¡ 1/2 ¡ 1/2 ¡

slide-18
SLIDE 18

Is ¡this ¡a ¡Markov ¡chain? ¡And ¡why? ¡

  • Yes. ¡Because ¡for ¡each ¡trial, ¡the ¡

probability ¡distribuRon ¡of ¡the ¡

  • utcomes ¡is ¡only ¡condiRoned ¡on ¡the ¡

previous ¡trial. ¡

slide-19
SLIDE 19

3 ¡ 1/2 ¡ 1/2 ¡ 1/2 ¡ 1/2 ¡

The ¡model ¡helps ¡form ¡recurrence ¡formula ¡

✺ Let ¡ ¡ ¡ ¡ ¡ ¡ ¡be ¡the ¡probability ¡of ¡stopping ¡aker ¡n ¡flips ¡ ¡ ✺ If ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡there ¡are ¡two ¡ways ¡the ¡sequence ¡starts ¡

✺ Toss ¡T ¡and ¡finish ¡in ¡n-­‑1 ¡tosses ¡ ✺ Or ¡toss ¡HT ¡and ¡finish ¡in ¡n-­‑2 ¡tosses ¡

✺ So ¡we ¡can ¡derive ¡a ¡recurrence ¡relaRon ¡

pn

p1 = 0 p2 = 1/4 p3 = 1/8 p4 = 1/8 n > 2

pn = 1 2pn−1 + 1 4pn−2

… ¡

slide-20
SLIDE 20

Transition ¡probability ¡matrix: ¡weather ¡ model ¡ ¡

✺ Let’s ¡model ¡daily ¡weather ¡as ¡one ¡of ¡the ¡three ¡states ¡

(Sunny, ¡Rainy, ¡and ¡Snowy) ¡with ¡Markov ¡chain ¡that ¡ has ¡the ¡transiRon ¡probabiliRes ¡as ¡shown ¡here. ¡

0.7 ¡ 0.6 ¡ 0.5 ¡ 0.2 ¡ 0.2 ¡ 0.1 ¡ 0.4 ¡ 0.1 ¡ 0.2 ¡

slide-21
SLIDE 21

Transition ¡probability ¡matrix: ¡weather ¡ model ¡ ¡

✺ Let’s ¡model ¡daily ¡weather ¡as ¡one ¡of ¡the ¡three ¡states ¡

(Sunny, ¡Rainy, ¡and ¡Snowy) ¡with ¡Markov ¡chain ¡that ¡ has ¡the ¡transiRon ¡probabiliRes ¡as ¡shown ¡here. ¡

0.7 ¡ 0.6 ¡ 0.5 ¡ 0.2 ¡ 0.2 ¡ 0.1 ¡ 0.4 ¡ 0.1 ¡ 0.2 ¡

P =   0.7 0.2 0.1 0.2 0.6 0.2 0.4 0.1 0.5  

Sunny ¡ Rainy ¡ Snowy ¡ Sunny ¡ Rainy ¡ Snowy ¡ i, ¡the ¡current ¡state ¡at ¡Rme ¡point ¡t ¡ j, ¡the ¡next ¡state ¡at ¡Rme ¡point ¡t+1 ¡

The ¡transiRon ¡probability ¡matrix ¡

1 ¡ 2 ¡ 3 ¡

slide-22
SLIDE 22

Q: ¡The ¡transition ¡probabilities ¡for ¡a ¡node ¡sum ¡to ¡1 ¡

  • A. ¡Yes. ¡ ¡
  • B. ¡No. ¡
slide-23
SLIDE 23

Transition ¡probability ¡matrix ¡properties ¡

✺ The ¡transiRon ¡probability ¡matrix ¡ ¡ ¡ ¡ ¡is ¡a ¡square ¡matrix ¡ ¡

with ¡entries ¡ ¡

✺ Since ¡ ¡

¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

pij

P

pij = P(Xt = j|Xt−1 = i)

pij ≥ 0

  • j

pij = 1

and ¡

P =   0.7 0.2 0.1 0.2 0.6 0.2 0.4 0.1 0.5  

Sunny ¡ Rainy ¡ Snowy ¡ Sunny ¡ Rainy ¡ Snowy ¡

The ¡transiRon ¡probability ¡matrix ¡

slide-24
SLIDE 24

Probability ¡distributions ¡over ¡states ¡

✺ Let ¡ ¡ ¡ ¡ ¡ ¡be ¡a ¡row ¡vector ¡containing ¡the ¡probability ¡

distribuRon ¡over ¡states ¡at ¡t=0 ¡

✺ For ¡example: ¡if ¡it ¡is ¡rainy ¡today, ¡and ¡today ¡is ¡t=0, ¡then ¡ ¡ ✺ Let ¡P(t) ¡ ¡be ¡a ¡row ¡vector ¡containing ¡the ¡probability ¡

distribuRon ¡over ¡states ¡at ¡Rme ¡point ¡t ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

π

πi = P(X0 = i) π = 1

slide-25
SLIDE 25

Propagating ¡the ¡probability ¡distribution ¡ ¡

P (1)

j

= P(X1 = j)

=

  • i

P(X1 = j, X0 = i) =

  • i

P(X1 = j|X0 = i)P(X0 = i) =

  • i

pijπi

✺ PropagaRng ¡from ¡t=0 ¡to ¡t=1, ¡ ✺ In ¡matrix ¡notaRon, ¡

p(1) = πP

slide-26
SLIDE 26

Probability ¡distributions: ¡

✺ Suppose ¡that ¡it ¡is ¡rainy, ¡we ¡have ¡the ¡iniRal ¡probability ¡

  • distribuRon. ¡

✺ What ¡are ¡the ¡probability ¡distribuRons ¡for ¡tomorrow ¡

and ¡the ¡day ¡aker ¡tomorrow? ¡

π = 1

p(1) = πP

p(2) = p(1)P

slide-27
SLIDE 27

Propagating ¡to ¡t= ¡∞ ¡

✺ We ¡have ¡just ¡seen ¡that ¡ ¡ ✺ So ¡in ¡general ¡ ¡

p(2) = p(1)P = (πP)P = πP 2

p(t) = πP t

✺ If ¡one ¡state ¡can ¡be ¡reached ¡from ¡any ¡other ¡state ¡in ¡the ¡

graph, ¡the ¡Markov ¡chain ¡is ¡called ¡irreducible ¡(single ¡chain). ¡

✺ Furthermore ¡, ¡if ¡it ¡saRsfies: ¡

¡then ¡the ¡Markov ¡chain ¡is ¡staRonary ¡and ¡S ¡is ¡the ¡ ¡staRonary ¡distribuRon. ¡

slide-28
SLIDE 28

Stationary ¡distribution ¡

✺ The ¡staRonary ¡distribuRon ¡ ¡ ¡ ¡ ¡ ¡has ¡the ¡following ¡

property: ¡ ¡

✺ ¡ ¡ ¡ ¡is ¡a ¡row ¡eigenvector ¡of ¡P ¡with ¡eigenvalue ¡1 ¡ ¡ ✺ In ¡the ¡example ¡of ¡the ¡weather ¡model, ¡regardless ¡of ¡

the ¡iniRal ¡distribuRon, ¡

s

sP = s

s

S = lim

t→∞ π

  0.7 0.2 0.1 0.2 0.6 0.2 0.4 0.1 0.5  

t

= 18

37 11 37 8 37

slide-29
SLIDE 29

Example: ¡Up-­‑to-­‑date ¡or ¡behind ¡model ¡

1 ¡ 2 ¡

0.2 ¡ 0.6 ¡ 0.8 ¡ 0.4 ¡

State ¡1: ¡Up-­‑to-­‑date ¡ State ¡2: ¡Behind ¡

What’s ¡the ¡transi6on ¡matrix? ¡ If ¡I ¡start ¡with ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡what ¡is ¡ my ¡probability ¡of ¡being ¡up-­‑to-­‑ date ¡eventually? ¡ ¡

π = ¡[ ¡0, ¡1] ¡

slide-30
SLIDE 30

Examples ¡of ¡non-­‑stationary ¡Markov ¡ chains ¡

3 ¡ 1 ¡ 2 ¡

1.0 ¡ 1.0 ¡ 0.5 ¡ 0.5 ¡

Periodic ¡

3 ¡ 0.5 ¡ 0.5 ¡ 0.5 ¡ 0.5 ¡

Absorbing ¡

slide-31
SLIDE 31

PageRank ¡Example ¡

✺ How ¡to ¡rate ¡web ¡pages ¡objecRvely? ¡ ✺ The ¡PageRank ¡algorithm ¡by ¡Page ¡et ¡al. ¡made ¡Google ¡

successful ¡

✺ The ¡method ¡uRlized ¡Markov ¡chain ¡model ¡and ¡applied ¡

it ¡to ¡the ¡large ¡list ¡of ¡webpages. ¡

✺ To ¡illustrate ¡the ¡point, ¡we ¡use ¡a ¡small-­‑size ¡example ¡

and ¡assume ¡a ¡simple ¡sta6onary ¡model. ¡

slide-32
SLIDE 32

Suppose ¡we ¡are ¡randomly ¡surfing ¡a ¡ network ¡of ¡webpages ¡

A ¡ B ¡ C ¡

0.5 ¡ 0.5 ¡

D ¡ E ¡ H ¡ F ¡ G ¡

slide-33
SLIDE 33

Initialize ¡the ¡distribution ¡uniformly ¡

A ¡ B ¡ C ¡

0.5 ¡ 0.5 ¡

D ¡ E ¡ H ¡ F ¡ G ¡

π = ¡

t ¡= ¡0 ¡ 1/8 ¡ 1/8 ¡ 1/8 ¡ 1/8 ¡ 1/8 ¡ 1/8 ¡ 1/8 ¡ 1/8 ¡

slide-34
SLIDE 34

Update ¡the ¡distribution ¡iteratively ¡

A ¡ B ¡ C ¡

0.5 ¡ 0.5 ¡

D ¡ E ¡ H ¡ F ¡ G ¡

t ¡= ¡1 ¡ 8/16 ¡ 1/16 ¡ 1/16 ¡ 1/16 ¡ 1/16 ¡ 1/16 ¡ 2/16 ¡ 1/16 ¡

slide-35
SLIDE 35

Until ¡the ¡stationary ¡distribution ¡ ¡

A ¡ B ¡ C ¡

0.5 ¡ 0.5 ¡

D ¡ E ¡ H ¡ F ¡ G ¡

t ¡= ¡∞ ¡ 4/13 ¡ 2/13 ¡ 1/13 ¡ 1/13 ¡ 2/13 ¡ 1/13 ¡ 1/13 ¡ 1/13 ¡

slide-36
SLIDE 36

If ¡the ¡surfer ¡get ¡trapped ¡

A ¡ B ¡ C ¡

0.5 ¡ 0.5 ¡

D ¡ E ¡ H ¡ F ¡ G ¡

t ¡= ¡ 4/13 ¡ 2/13 ¡ 1/13 ¡ 1/13 ¡ 2/13 ¡ 1/13 ¡ 1/13 ¡ 1/13 ¡

✺ Allow ¡“teleport” ¡with ¡

small ¡probability ¡from ¡ any ¡page ¡to ¡another ¡

✺ Or ¡allow ¡“teleport” ¡

with ¡user ¡input ¡of ¡URL ¡

slide-37
SLIDE 37

Diverse ¡applications ¡of ¡Markov ¡Model ¡

✺ CommunicaRon ¡network ¡ ✺ Queue ¡modeling ¡ ✺ DNA ¡sequence ¡modeling ¡ ✺ Natural ¡language ¡processing ¡ ✺ Single-­‑cell ¡large ¡data ¡analysis ¡ ✺ Financial/Economic ¡model ¡ ✺ Music ¡

slide-38
SLIDE 38
  • Q. ¡Aren’t ¡you ¡interested? ¡
  • A. Yes. ¡
  • B. No. ¡
slide-39
SLIDE 39

Diverse ¡applications ¡of ¡Markov ¡Model ¡

✺ CommunicaRon ¡network ¡ ✺ Queue ¡modeling ¡ ✺ DNA ¡sequence ¡modeling ¡ ✺ Natural ¡language ¡processing ¡ ✺ Single-­‑cell ¡large ¡data ¡analysis ¡ ✺ Financial/Economic ¡model ¡ ✺ Music ¡

0.7 ¡ 0.6 ¡ 0.5 ¡ 0.2 ¡ 0.2 ¡ 0.1 ¡ 0.4 ¡ 0.1 ¡ 0.2 ¡

slide-40
SLIDE 40

Final ¡Exam ¡

✺ Time: ¡1:30pm ¡Mon. ¡Dec. ¡16 ¡ ✺ Place: ¡in ¡class, ¡DCL1320 ¡ ✺ DuraRon: ¡2hr30mins ¡ ✺ Content ¡coverage: ¡Ch1-­‑14, ¡except ¡8 ¡ ✺ Note ¡sheet: ¡2 ¡pages ¡(double ¡sided) ¡hand ¡wrifen ¡or ¡1 ¡page ¡

(double ¡sided, ¡not ¡limited ¡to ¡hand ¡wrifen) ¡

✺ Office ¡hours: ¡Instructor ¡is ¡having ¡open ¡office ¡policy. ¡TAs ¡don’t ¡

have ¡regular ¡OH, ¡but ¡may ¡be ¡available ¡upon ¡requests ¡

¡

slide-41
SLIDE 41

ICES ¡form ¡(instruction) ¡

✺ Read ¡the ¡instrucRon ¡ ✺ The ¡possible ¡opRonal ¡essay ¡quesRons: ¡

Ten ¡years ¡from ¡now ¡I’ll ¡probably ¡remember ¡this ¡course ¡most ¡by ¡

The ¡instructor’s ¡concern ¡for ¡students ¡

The ¡aspects ¡of ¡the ¡course ¡which ¡you ¡found ¡most ¡valuable ¡

The ¡aspects ¡of ¡the ¡course ¡which ¡you ¡found ¡least ¡valuable ¡

My ¡moRvaRon ¡to ¡do ¡well ¡in ¡this ¡course ¡

The ¡type ¡of ¡instrucRon ¡which ¡would ¡be ¡most ¡beneficial ¡for ¡this ¡course ¡

Your ¡effort ¡in ¡this ¡course ¡

Would ¡you ¡be ¡interested ¡in ¡becoming ¡a ¡tutor ¡for ¡the ¡subject? ¡

¡

slide-42
SLIDE 42

Additional ¡References ¡

✺ Peter ¡Dalgaard ¡"Introductory ¡StaRsRcs" ¡

with ¡R ¡

✺ Robert ¡V. ¡Hogg, ¡Elliot ¡A. ¡Tanis ¡and ¡Dale ¡L. ¡

  • Zimmerman. ¡“Probability ¡and ¡StaRsRcal ¡

Inference” ¡ ¡

✺ Kelvin ¡Murphy, ¡“Machine ¡learning, ¡A ¡

ProbabilisRc ¡perspecRve” ¡

slide-43
SLIDE 43

Acknowledgement ¡

Thank You!