Probability*and*Statistics* ! ! for*Computer*Science** - - PowerPoint PPT Presentation

probability and statistics
SMART_READER_LITE
LIVE PREVIEW

Probability*and*Statistics* ! ! for*Computer*Science** - - PowerPoint PPT Presentation

Probability*and*Statistics* ! ! for*Computer*Science** I!have!now!used!each!of!the! terms!mean,!variance,! covariance!and!standard! devia5on!in!two!slightly! different!ways.!<<<Prof.! Forsythe!! ! Credit:!wikipedia!


slide-1
SLIDE 1

!!

Probability*and*Statistics* for*Computer*Science**

“I!have!now!used!each!of!the! terms!mean,!variance,! covariance!and!standard! devia5on!in!two!slightly! different!ways.”!<<<Prof.! Forsythe!! !

Hongye!Liu,!Teaching!Assistant!Prof,!CS361,!UIUC,!2.13.2020! Credit:!wikipedia!

slide-2
SLIDE 2

Last*time*

Random!Variable!!

The!Defini5on!of!Random!Variable! Probability*distribu.on!of!random!

variable!

Joint*&*Condi.onal*probability*

distribu.on!of!random!variable!

slide-3
SLIDE 3

Content*

Random!Variable!!

Expected*value* Variance*&*covariance! Markov’s*inequality!

slide-4
SLIDE 4

Three*important*facts*of* Random*variables*

Random!variables!have!

probability*func/ons*

Random!variables!can!be!

condi/oned!on!events!or!other! random!variables!

Random!variables!have!averages*

slide-5
SLIDE 5

Content*

Random!Variable!!

Expected(value( Variance*&*covariance! Markov’s*inequality!

slide-6
SLIDE 6

Expected*value*

The!expected*value!(or!expecta/on)!

  • f!a!random!variable!X!is!

The!expected!value!is!a!weighted!sum!

  • f!the!values!X!can!take!

!

E[X] =

  • x

xP(x)

pc X=k)

  • " possible value
slide-7
SLIDE 7

Expected*value*

The!expected*value!of!a!random!

variable!X!is!

The!expected!value!is!a!weighted!sum!

  • f!the!values!X!can!take!

!

E[X] =

  • x

xP(x)

<=!1! Ep # =L

N

slide-8
SLIDE 8

Expected(value:(profit((

A"company"has"a"project"that"has"p"

probability"of"earning"10"million"and"1#p" probability"of"losing"10"million."

Let"X"be"the"return"of"the"project."

"

E- EX) =

to Pt f -lo) ( t - P )

=

cop

  • to

> o

P S

,

0.5

co profit

slide-9
SLIDE 9

Expected*value:*profit**

A!company!has!a!project!that!has!p!

probability!of!earning!10!million!and!1.p! probability!of!losing!10!million.!

Let!X!be!the!return!of!the!project.!

!

E[X] = 10p + (−10)(1 − p)

= 20p − 10

For E[X] > 0 we need p > 0.5

slide-10
SLIDE 10

wrhies

5

ME TE FE ¥7

Mean

= ? I

  • t

$1 each

92 each

A) random

draw

I

Expected

value = ?

0.75×11-0.25×2

= Ig

D) random

draw

1 twice

with

replacement

indeputy

( if

the

two

draws

are

the

game .

You

3

get

the prize, w -4 %

$1

Expected

value

=

? w 3-It

is

  • /

4

4

16

g

\t - Z

,

TE

  • Tbxltgxz

= It

eh 4h

  • h}

To → $2

slide-11
SLIDE 11

Expected*value*as*mean**

Suppose!we!have!a!data!set!{xi}!of!N!data!

points.!Let’s!define!a!random!variable!X! taking!on!each!of!the!data!points!with! equal!probability!1/N.!!

The!expected!value!is!also!called!the!

mean.!

!

E[X] =

  • i

xiP(xi) = 1

N

  • i

xi = mean({xi})

slide-12
SLIDE 12

Linearity*of*Expectation*

For!random!variables!X!and!Y!

and!constants!k,c!

Scaling!property!

!

Addi5vity! And!!

E[X + Y ] = E[X] + E[Y ]

E[kX] = kE[X]

E[kX + c] = kE[X] + c

F

slide-13
SLIDE 13

Linearity*of*Expectation*

Proof!of!the!addi5ve!property! !

!

E[X + Y ] = E[X] + E[Y ]

E-Cx t'll = I 5g

Ht 2) PHo=xo=y)

next

pg

slide-14
SLIDE 14

E Ext Y) = I -2g

(key) P CX

  • x, F- y,

= I -2g

cuty, pox. y )

=

TZ Fy apex,y ) t § I y poky,

y

=

Ee k Ey

Pl x. y l t Ey §

y pi x.y,

= Iaz

t Ey 2Epcx

d p ck)

ptcy,

= Ty xp ex) t Tg y pay, =

E-Cx) t ECT)

slide-15
SLIDE 15

Linearity*of*Expectation*

Proof!of!the!addi5ve!property! !

!

E[X + Y ] = E[X] + E[Y ]

E[X + Y ] =

  • x
  • y

(x + y)P(x, y)

P({X = x} ∩ {Y = y})

slide-16
SLIDE 16

Linearity*of*Expectation*

!

!

E[X + Y ] =

  • x
  • y

(x + y)P(x, y) =

  • x
  • y

xP(x, y) +

  • x
  • y

yP(x, y) =

  • x
  • y

xP(x, y) +

  • y
  • x

yP(x, y) =

  • x

x

  • y

P(x, y) +

  • y

y

  • x

P(x, y) =

  • x

xP(x) +

  • y

yP(y)

slide-17
SLIDE 17

Linearity*of*Expectation*

!

!

E[X + Y ] =

  • x
  • y

(x + y)P(x, y) =

  • x
  • y

xP(x, y) +

  • x
  • y

yP(x, y) =

  • x
  • y

xP(x, y) +

  • y
  • x

yP(x, y) =

  • x

x

  • y

P(x, y) +

  • y

y

  • x

P(x, y) =

  • x

xP(x) +

  • y

yP(y)

= E[X] + E[Y ]

slide-18
SLIDE 18

Q.*What’s*the*value?*

What!is!E[E[X]+1]?!

!!!!!A.!E[X]+1!!!!!!!B.!1!!!!!!!!C.!0!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

e

slide-19
SLIDE 19

Expected*value*of*a*function*of*X

If!f!is!a!func5on!of!a!random!

variable!X!,!then!Y!=!f!(X)!is!a! random!variable!too!

The!expected!value!of!Y!=!f!(X)!is! !

!

Eff Gi ) = E y

  • = -2 fixspc
slide-20
SLIDE 20

Expected*value*of*a*function*of*X

If!f!is!a!func5on!of!a!random!

variable!X!,!then!Y!=!f!(X)!is!a! random!variable!too!

The!expected!value!of!Y!=!f!(X)!is! !

!

E[Y ] = E[f(X)] =

  • x

f(x)P(x)

slide-21
SLIDE 21

Expected*time*of*cat*

A!cat!moves!with!random!constant!

speed!V,!either!5mile/hr!or!20mile/hr! with!equal!probability,!what’s!the! expected!5me!for!it!to!travel!50!miles?!

!

!

EW)

= WE

T=fwt=¥=E

EF¥¥j4

ECT ) -_ El

I

=

. plV=Y) tupcv=Vu,

=

xtz-E-xtz-6.vn.

Z

slide-22
SLIDE 22

Expected*time*of*cat*

A!cat!moves!with!random!constant!

speed!V,!either!5mile/hr!or!20mile/hr! with!equal!probability,!what’s!the! expected!5me!for!it!to!travel!50!miles?!

!

!

t(V ) = 50 V

E[t(V )] =

  • v

50 v P(v) = 50 5 × 1 2 + 50 20 × 1 2 = 6.25 hours

slide-23
SLIDE 23

Q:*Is*this*statement*true?**

If!there!exists!a!constant!such!that! P(X!≥!a)!=!!1,!then!E[X]!≥!a!.!It!is:! !

  • A. True!
  • B. False!

I

n

Fas

E Cx)

  • I xpex
  • x,

= Esa xp

+ Ea E

'?FE'aa

slide-24
SLIDE 24

Q:*Is*this*statement*true?**

If!there!exists!a!constant!such!that! P(X!≥!a)!=!!1,!then!E[X]!≥!a!.!It!is:! !

  • A. True!
  • B. False!

E[X] =

x<a

  • −∞

xP(X = x) +

  • a

xP(X = x)

0!

≥a!

slide-25
SLIDE 25

Content*

Random!Variable!!

Expected*value* Variance(&(covariance* Towards*the*week*law*of*large*

numbers!

slide-26
SLIDE 26

Variance*and*standard*deviation

The!variance!of!a!random!

variable!X!is!

The!standard!devia5on!of!a!

random!variable!X!is!

!

std[X] =

  • var[X]

var[X] = E[(X − E[X])2]

var (fXi) > = I

l Xi- meanCl ki 35

IN

ga

slide-27
SLIDE 27

Properties*of*variance

For!random!variable!X!and!

constant!k!

!

!

!

var[kX] = k2var[X] var[X] ≥ 0

non - negative !

E

p

scaling

with

squared

K

slide-28
SLIDE 28

A*neater*expression*for*variance

!

!

var[X] = E[X2] − E[X]2

var[X] = E[(X − E[X])2]

Variance!of!Random!Variable!X!is!

defined!as:!!

It’s!the!same!as:!

slide-29
SLIDE 29

A*neater*expression*for*variance

!

!

var[X] = E[(X − E[X])2]

n -_ Efx]

= El XII MX

tu ' ]

=

Efx'T - 2E -4×1 + Elm')

= ECI ) - 2h ECXJTNZ

=

ECI ) - ZEEXIETXITETX ]

=

ECW)

  • E'Cx )
slide-30
SLIDE 30

A*neater*expression*for*variance

!

!

var[X] = E[(X − µ)2] where µ = E[X] = E[X2 − 2Xµ + µ2] = E[X2] − 2µE[X] + µ2 var[X] = E[(X − E[X])2] By!linearity!of!expecta5on!

slide-31
SLIDE 31

A*neater*expression*for*variance

!

!

var[X] = E[(X − µ)2] where µ = E[X] = E[X2 − 2Xµ + µ2] = E[X2] − 2µE[X] + µ2 = E[X2] − 2E[X]E[X] + (E[X])2 var[X] = E[(X − E[X])2]

slide-32
SLIDE 32

A*neater*expression*for*variance

!

!

var[X] = E[(X − µ)2] where µ = E[X] = E[X2 − 2Xµ + µ2] = E[X2] − 2µE[X] + µ2 = E[X2] − 2E[X]E[X] + (E[X])2 = E[X2] − E[X]2 var[X] = E[(X − E[X])2]

slide-33
SLIDE 33

Variance:*the*profit*example*

For!the!profit!example,!what!is!the!

variance!of!the!return?!We!know!E[X]=! 20p<10! var[X] = E[X2] − (E[X])2 = (102p + (−10)2(1 − p)) − (20p − 10)2 = 100 − (400p2 − 400p + 100) = 400p(1 − p)

! ! ! ! ! !

  • PCX=k)=fB

x' to

Solve infgroup

y

'TP

x

  • to
  • 2

ktpck )

Cup

  • cop

2C

10? -

p +

C-lo)'ll-:p)

slide-34
SLIDE 34

Variance:*the*profit*example*

For!the!profit!example,!what!is!the!

variance!of!net!return?!We!know!E[X]=! 20p<10! var[X] = E[X2] − (E[X])2 = (102p + (−10)2(1 − p)) − (20p − 10)2 = 100 − (400p2 − 400p + 100) = 400p(1 − p)

! ! ! ! ! !

slide-35
SLIDE 35

Variance:*the*profit*example*

For!the!profit!example,!what!is!the!

variance!of!net!return?!We!know!E[X]=! 20p<10! var[X] = E[X2] − (E[X])2 = (102p + (−10)2(1 − p)) − (20p − 10)2 = 100 − (400p2 − 400p + 100) = 400p(1 − p)

! ! ! ! !

slide-36
SLIDE 36

Variance:*the*profit*example*

For!the!profit!example,!what!is!the!

variance!of!net!return?!We!know!E[X]=! 20p<10! var[X] = E[X2] − (E[X])2 = (102p + (−10)2(1 − p)) − (20p − 10)2 = 100 − (400p2 − 400p + 100) = 400p(1 − p)

slide-37
SLIDE 37

Motivation*for*covariance*

Study!the!rela5onship!between!

random!variables*

Note!that!it’s!the!un<normalized!

correla5on!

Applica5ons!include!the!fire!control!

  • f!radar,!communica5ng!in!the!

presence!of!noise.!!

slide-38
SLIDE 38

Covariance*

The*covariance!of!random!

variables!X!and!Y!is!

Note!that!

cov(X, Y ) = E[(X − E[X])(Y − E[Y ])]

cov(X, X) = E[(X − E[X])2] = var[X]

a- . *Iii

'

j Eam ix. Es

slide-39
SLIDE 39

A*neater*form*for*covariance*

A!neater!expression!for*

covariance!(similar!deriva5on!as! for!variance)!

cov(X, Y ) = E[XY ] − E[X]E[Y ]

slide-40
SLIDE 40

Correlation*coefficient*is* normalized**covariance*

The!correla5on!coefficient!is!

*

When!X, Y!takes!on!values!with!equal!

probability!to!generate!data!sets! {(x,y)},!the!correla5on!coefficient!will! be!as!seen!in!Chapter!2.!

corr(X, Y ) = cov(X, Y ) σXσY

00

slide-41
SLIDE 41

Correlation*coefficient*is* normalized**covariance*

The!correla5on!coefficient!can!also!be!

wriken!as:!

* corr(X, Y ) = E[XY ] − E[X]E[Y ]

σXσY

Cov CX, Y

)

L

slide-42
SLIDE 42

Correlation*seen*from*scatter*plots*

Posi5ve!! correla5on! ! Nega5ve!! correla5on! Zero!! Correla5on! !

Credit:! Prof.Forsyth!

slide-43
SLIDE 43

Covariance*seen*from*scatter*plots*

Posi5ve!! Covariance! ! Nega5ve!! Covariance! Zero!! Covariance! !

Credit:! Prof.Forsyth!

slide-44
SLIDE 44

When*correlation*coefficient*or* covariance*is*zero**

The!covariance!is!0!! That!is:! This!is!a!necessary!property!of!

independence!of!random!variables!*!(not! equal!to!independence)!

E[XY ] − E[X]E[Y ] = 0 E[XY ] = E[X]E[Y ]

→-

slide-45
SLIDE 45

Variance*of*the*sum*of*two*random* variables*

var[X + Y ] = var[X] + var[Y ] + 2cov(X, Y )

slide-46
SLIDE 46

Properties*of*independence*in* terms*of*expectations*

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

E[XY ] = E[X]E[Y ]

"' ECXYI-E-zxyplk-x.tk#.:.dp+

=D

my pix) ply ,

← x. y

I

n pix) j ypay)

= -

=

Efx ) ECT]

→CoV ( x ,2) = Efx's - Efx ) El Y) = o

slide-47
SLIDE 47

Proof*of*independence*in*terms*

  • f*expectation*(1)*

!

E[XY ] = E[X]E[Y ]

E[XY ] =

  • (x,y)∈Dx×Dy

xyP(X = x ∩ Y = y) =

  • x∈Dx
  • y∈Dy

(xyP(x, y)) =

  • x∈Dx
  • y∈Dy

(xyP(x)P(y)) =

  • x∈Dx

xP(x)

  • y∈Dy

yP(y) = (

  • x∈Dx

xP(x))(

  • y∈Dy

yP(y)) = E[X]E[Y ]

slide-48
SLIDE 48

Properties*of*independence*in* terms*of*expectations*

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

E[XY ] = E[X]E[Y ]

cov(X, Y ) = 0

var[X + Y ] = var[X] + var[Y ]

1

slide-49
SLIDE 49

Q:*What*is*this*expectation?*

We!toss!two!iden5cal!coins!A!&!B!

independently!for!three!5mes!and!4!5mes! respec5vely,!for!each!head!we!earn!$1,!we! define!X!is!the!earning!from!A!and!Y!is!the! earning!from!B.!What!is!E(XY)?! !!!!!A.!$2!!!!!!!B.!$3!!!!!!!!C.!$4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

fair

R

a

Efx:3

EXH-EECxil-Z-txitfxoECYI-EEfy.it

# X 's

= 's

slide-50
SLIDE 50

Group*Discussion*

If!two!random!variables!are!

uncorrelated,!does!this!mean!they!are! independent?!Inves5gate!the!case!X! takes!<1,!0,!1!with!equal!probability! and!Y=X2.!

+

  • 3

EM

ELY )

Ecxyy

EIXY )

  • 1×4+0×5#

" x } teeny

= EN )

=O

=u

= Ixtztoxtztlxtz

slide-51
SLIDE 51

Y

y

I

* I

'

*

:

:*:*.

i

"

÷

' ie

.E V

'

t

slide-52
SLIDE 52

Covariance*example*

It’s!an!underlying!concept!in!principal! component!analysis!in!Chapter!10!!!!!!!!!!!!!!!!!!

slide-53
SLIDE 53

Assignments)

Finish&Chapter&4&of&the&textbook& Next&4me:&Proof&of&Markov&inequality,&

Chebyshev&inequality&&&Weak&law&of& large&numbers,&Con4nuous&random& variable&

&

slide-54
SLIDE 54

Additional*References*

Charles!M.!Grinstead!and!J.!Laurie!Snell!

"Introduc5on!to!Probability”!!

Morris!H.!Degroot!and!Mark!J.!Schervish!

"Probability!and!Sta5s5cs”!

slide-55
SLIDE 55

See*you*next*time*

See You!