cse 473: artificial intelligence topics from 30,000’ probability we · 2017-05-05 · 5 the...

8
1 CSE 473: Artificial Intelligence Probability Dieter Fox University of Washington [These slides were created by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley. All CS188 materials are available at http://ai.berkeley.edu.] Topics from 30,000’ § Were done with Part I Search and Planning! § Part II: Probabilistic Reasoning § Diagnosis § Speech recognition § Tracking objects § Robot mapping § Genetics § Error correcting codes § … lots more! § Part III: Machine Learning Outline § Probability § Random Variables § Joint and Marginal Distributions § Conditional Distribution § Product Rule, Chain Rule, Bayes’ Rule § Inference § Independence § You’ll need all this stuff A LOT for the next few weeks, so make sure you go over it now! Uncertainty § General situation: § Observed variables (evidence): Agent knows certain things about the state of the world (e.g., sensor readings or symptoms) § Unobserved variables: Agent needs to reason about other aspects (e.g. where an object is or what disease is present) § Model: Agent knows something about how the known variables relate to the unknown variables § Probabilistic reasoning gives us a framework for managing our beliefs and knowledge What is….? W P sun 0.6 rain 0.1 fog 0.3 meteor 0.0 Random Variable } Value Probability Distribution Joint Distributions § A joint distribution over a set of random variables: specifies a probability for each assignment (or outcome): § Must obey: § Size of joint distribution if n variables with domain sizes d? § For all but the smallest distributions, impractical to write out! T W P hot sun 0.4 hot rain 0.1 cold sun 0.2 cold rain 0.3

Upload: others

Post on 10-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE 473: Artificial Intelligence Topics from 30,000’ Probability We · 2017-05-05 · 5 The Product Rule § Example: R P sun 0.8 rain 0.2 D W P wet sun 0.1 dry sun0.9 wet rain 0.7

1

CSE473:ArtificialIntelligence

Probability

DieterFoxUniversityofWashington

[TheseslideswerecreatedbyDanKleinandPieterAbbeelforCS188IntrotoAIatUCBerkeley.AllCS188materialsareavailableathttp://ai.berkeley.edu.]

Topicsfrom30,000’

§ We’redonewithPartISearchandPlanning!

§ PartII:ProbabilisticReasoning§ Diagnosis§ Speechrecognition§ Trackingobjects§ Robotmapping§ Genetics§ Errorcorrectingcodes§ …lotsmore!

§ PartIII:MachineLearning

Outline

§ Probability§ RandomVariables§ JointandMarginalDistributions§ ConditionalDistribution§ ProductRule,ChainRule,Bayes’Rule§ Inference§ Independence

§ You’llneedallthisstuffALOTforthenextfewweeks,somakesureyougooveritnow!

Uncertainty

§ Generalsituation:

§ Observedvariables(evidence):Agentknowscertainthingsaboutthestateoftheworld(e.g.,sensorreadingsorsymptoms)

§ Unobservedvariables:Agentneedstoreasonaboutotheraspects(e.g.whereanobjectisorwhatdiseaseispresent)

§ Model:Agentknowssomethingabouthowtheknownvariablesrelatetotheunknownvariables

§ Probabilisticreasoninggivesusaframeworkformanagingourbeliefsandknowledge

Whatis….?

W Psun 0.6rain 0.1fog 0.3

meteor 0.0

?

?

Random Variable

}?Value

Probability Distribution

JointDistributions§ Ajointdistribution overasetofrandomvariables:

specifiesaprobabilityforeachassignment(oroutcome):

§ Mustobey:

§ Sizeofjointdistributionifnvariableswithdomainsizesd?

§ Forallbutthesmallestdistributions,impracticaltowriteout!

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

Page 2: CSE 473: Artificial Intelligence Topics from 30,000’ Probability We · 2017-05-05 · 5 The Product Rule § Example: R P sun 0.8 rain 0.2 D W P wet sun 0.1 dry sun0.9 wet rain 0.7

2

ProbabilisticModels

§ Aprobabilisticmodelisajointdistributionoverasetofrandomvariables

§ Probabilisticmodels:§ (Random)variableswithdomains§ Jointdistributions:saywhetherassignments

(called“outcomes”)arelikely§ Normalized:sumto1.0§ Ideally:onlycertainvariablesdirectlyinteract

§ Constraintsatisfactionproblems:§ Variableswithdomains§ Constraints:statewhetherassignmentsarepossible§ Ideally:onlycertainvariablesdirectlyinteract

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

T W Phot sun Thot rain Fcold sun Fcold rain T

DistributionoverT,W

ConstraintoverT,W

Events

§ Anevent isasetEofoutcomes

§ Fromajointdistribution,wecancalculatetheprobabilityofanyevent§ Probabilitythatit’shotANDsunny?

§ Probabilitythatit’shot?

§ Probabilitythatit’shotORsunny?

§ Typically,theeventswecareaboutarepartialassignments,likeP(T=hot)

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

Quiz:Events

§ P(+x,+y)?

§ P(+x)?

§ P(-yOR+x)?

X Y P+x +y 0.2+x -y 0.3-x +y 0.4-x -y 0.1

MarginalDistributions

§ Marginaldistributionsaresub-tableswhicheliminatevariables§ Marginalization (summingout):Combinecollapsedrowsbyadding

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

T Phot 0.5cold 0.5

W Psun 0.6rain 0.4

Quiz:MarginalDistributions

X Y P+x +y 0.2+x -y 0.3-x +y 0.4-x -y 0.1

X P+x-x

Y P+y-y

ConditionalProbabilities§ Asimplerelationbetweenjointandmarginalprobabilities

§ Infact,thisistakenasthedefinitionofaconditionalprobability

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

P(b)P(a)

P(a,b)

Page 3: CSE 473: Artificial Intelligence Topics from 30,000’ Probability We · 2017-05-05 · 5 The Product Rule § Example: R P sun 0.8 rain 0.2 D W P wet sun 0.1 dry sun0.9 wet rain 0.7

3

Quiz:ConditionalProbabilities

X Y P+x +y 0.2+x -y 0.3-x +y 0.4-x -y 0.1

§ P(+x|+y)?

§ P(-x|+y)?

§ P(-y|+x)?

ConditionalDistributions

§ Conditionaldistributionsareprobabilitydistributionsoversomevariablesgivenfixedvaluesofothers

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

W Psun 0.8rain 0.2

W Psun 0.4rain 0.6

ConditionalDistributions JointDistribution

ConditionalDistribs - TheSlowWay…

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

W Psun 0.4rain 0.6

SELECT thejointprobabilitiesmatchingtheevidence

NormalizationTrick

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

W Psun 0.4rain 0.6

T W Pcold sun 0.2cold rain 0.3

NORMALIZEtheselection

(makeitsumtoone)

NormalizationTrick

T W Phot sun 0.4hot rain 0.1cold sun 0.2cold rain 0.3

W Psun 0.4rain 0.6

T W Pcold sun 0.2cold rain 0.3

SELECT thejointprobabilitiesmatchingtheevidence

NORMALIZEtheselection

(makeitsumtoone)

§ Whydoesthiswork?SumofselectionisP(evidence)!(P(T=c),here)

Quiz:NormalizationTrick

X Y P+x +y 0.2+x -y 0.3-x +y 0.4-x -y 0.1

SELECT thejointprobabilitiesmatchingtheevidence

NORMALIZEtheselection

(makeitsumtoone)

§ P(X|Y=-y)?

Page 4: CSE 473: Artificial Intelligence Topics from 30,000’ Probability We · 2017-05-05 · 5 The Product Rule § Example: R P sun 0.8 rain 0.2 D W P wet sun 0.1 dry sun0.9 wet rain 0.7

4

§ Dictionary: “Tobringorrestoretoanormalcondition“

§ Procedure:§ Step1:ComputeZ=sumoverallentries§ Step2:DivideeveryentrybyZ

§ Example1

ToNormalize

All entries sum to ONE

W Psun 0.2rain 0.3 Z = 0.5

W Psun 0.4rain 0.6

§ Example2T W P

hot sun 20

hot rain 5

cold sun 10

cold rain 15

Normalize

Z = 50

NormalizeT W P

hot sun 0.4

hot rain 0.1

cold sun 0.2

cold rain 0.3

ProbabilisticInference

§ Probabilisticinference=“computeadesiredprobabilityfromotherknownprobabilities(e.g.conditionalfromjoint)”

§ Wegenerallycomputeconditionalprobabilities§ P(ontime|noreportedaccidents)=0.90§ Theserepresenttheagent’sbeliefs giventheevidence

§ Probabilitieschangewithnewevidence:§ P(ontime|noaccidents,5a.m.)=0.95§ P(ontime|noaccidents,5a.m.,raining)=0.80§ Observingnewevidencecausesbeliefstobeupdated

InferencebyEnumeration§ Generalcase:

§ Evidencevariables:§ Query*variable:§ Hiddenvariables: Allvariables

*Worksfinewithmultiplequeryvariables,too

§ Wewant:

§ Step1:Selecttheentriesconsistentwiththeevidence

§ Step2:SumoutHtogetjointofQueryandevidence

§ Step3:Normalize

⇥ 1

Z

InferencebyEnumeration

§ P(W)?

§ P(W |winter)?

§ P(W |winter,hot)?

S T W Psumme

rhot sun 0.30

summer

hot rain 0.05

summer

cold sun 0.10

summer

cold rain 0.05

winter hot sun 0.10winter hot rain 0.05winter cold sun 0.15winter cold rain 0.20

§ Computationalproblems?

§ Worst-casetimecomplexityO(dn)

§ SpacecomplexityO(dn)tostorethejointdistribution

InferencebyEnumeration TheProductRule

§ Sometimeshaveconditionaldistributionsbutwantthejoint

Page 5: CSE 473: Artificial Intelligence Topics from 30,000’ Probability We · 2017-05-05 · 5 The Product Rule § Example: R P sun 0.8 rain 0.2 D W P wet sun 0.1 dry sun0.9 wet rain 0.7

5

TheProductRule

§ Example:

R P

sun 0.8

rain 0.2

D W P

wet sun 0.1

dry sun 0.9

wet rain 0.7

dry rain 0.3

D W P

wet sun 0.08

dry sun 0.72

wet rain 0.14

dry rain 0.06

TheChainRule

§ Moregenerally,canalwayswriteanyjointdistributionasanincrementalproductofconditionaldistributions

Independence

§ Twovariablesareindependent inajointdistributionif:

§ Saysthejointdistributionfactors intoaproductoftwosimpleones§ Usuallyvariablesaren’tindependent!

§ Canuseindependenceasamodelingassumption§ Independencecanbeasimplifyingassumption§ Empiricaljointdistributions:atbest“close”toindependent§ Whatcouldweassumefor{Weather,Traffic,Cavity}?

§ IndependenceislikesomethingfromCSPs:what?

Example:Independence?

T W P

hot sun 0.4

hot rain 0.1

cold sun 0.2

cold rain 0.3

T W P

hot sun 0.3

hot rain 0.2

cold sun 0.3

cold rain 0.2

T P

hot 0.5

cold 0.5

W P

sun 0.6

rain 0.4

P2(T,W ) = P (T )P (W )

Example:Independence

§ Nfair,independentcoinflips:

H 0.5

T 0.5

H 0.5

T 0.5

H 0.5

T 0.5

ConditionalIndependence

Page 6: CSE 473: Artificial Intelligence Topics from 30,000’ Probability We · 2017-05-05 · 5 The Product Rule § Example: R P sun 0.8 rain 0.2 D W P wet sun 0.1 dry sun0.9 wet rain 0.7

6

ConditionalIndependence§ P(Toothache,Cavity,Catch)

§ IfIhaveacavity,theprobabilitythattheprobecatchesinitdoesn'tdependonwhetherIhaveatoothache:§ P(+catch|+toothache,+cavity)=P(+catch|+cavity)

§ ThesameindependenceholdsifIdon’thaveacavity:§ P(+catch|+toothache,-cavity)=P(+catch|-cavity)

§ Catchisconditionallyindependent ofToothachegivenCavity:§ P(Catch|Toothache,Cavity)=P(Catch|Cavity)

§ Equivalentstatements:§ P(Toothache|Catch,Cavity)=P(Toothache|Cavity)§ P(Toothache,Catch|Cavity)=P(Toothache|Cavity)P(Catch|Cavity)§ Onecanbederivedfromtheothereasily

ConditionalIndependence

§ Unconditional(absolute)independenceveryrare(why?)

§ Conditionalindependence isourmostbasicandrobustformofknowledgeaboutuncertainenvironments.

§ XisconditionallyindependentofYgivenZ

ifandonlyif:

or,equivalently,ifandonlyif

ConditionalIndependence

§ Whataboutthisdomain:

§ Traffic§ Umbrella§ Raining

ConditionalIndependence

§ Whataboutthisdomain:

§ Fire§ Smoke§ Alarm

BayesRule Pacman – Sonar(P4)

[Demo:Pacman – Sonar– NoBeliefs(L14D1)]

Page 7: CSE 473: Artificial Intelligence Topics from 30,000’ Probability We · 2017-05-05 · 5 The Product Rule § Example: R P sun 0.8 rain 0.2 D W P wet sun 0.1 dry sun0.9 wet rain 0.7

7

VideoofDemoPacman – Sonar(nobeliefs) Bayes’Rule

§ Twowaystofactorajointdistributionovertwovariables:

§ Dividing,weget:

§ Whyisthisatallhelpful?

§ Letsusbuildoneconditionalfromitsreverse§ Oftenoneconditionalistrickybuttheotheroneissimple§ Foundationofmanysystemswe’llseelater(e.g.ASR,MT)

§ IntherunningformostimportantAIequation!

That’smyrule!

InferencewithBayes’Rule

§ Example:Diagnosticprobabilityfromcausalprobability:

§ Example:§ M:meningitis,S:stiffneck

§ Note:posteriorprobabilityofmeningitisstillverysmall§ Note:youshouldstillgetstiffneckscheckedout!Why?

Examplegivens

P (+s|�m) = 0.01

P (+m|+ s) =P (+s|+m)P (+m)

P (+s)=

P (+s|+m)P (+m)

P (+s|+m)P (+m) + P (+s|�m)P (�m)=

0.8⇥ 0.0001

0.8⇥ 0.0001 + 0.01⇥ 0.9999= 0.007937

P (+m) = 0.0001P (+s|+m) = 0.8

P (cause|e↵ect) = P (e↵ect|cause)P (cause)

P (e↵ect)

=0.0079

GhostbustersSensorModel

40

P(red|3) P(orange|3) P(yellow|3) P(green|3)0.05 0.15 0.5 0.3

Real Distance = 3

Values of Pacman’s Sonar Readings

Ghostbusters,Revisited

§ Let’ssaywehavetwodistributions:§ Priordistributionoverghostlocation:P(G)

§ Let’ssaythisisuniform§ Sensorreadingmodel:P(R|G)

§ Given:weknowwhatoursensorsdo§ R=readingcolormeasuredat(1,1)§ E.g.P(R=yellow|G=(1,1))=0.1

§ WecancalculatetheposteriordistributionP(G|r)overghostlocationsgivenareadingusingBayes’rule:

[Demo:Ghostbuster– withprobability(L12D2)]

VideoofDemoGhostbusterswithProbability

Page 8: CSE 473: Artificial Intelligence Topics from 30,000’ Probability We · 2017-05-05 · 5 The Product Rule § Example: R P sun 0.8 rain 0.2 D W P wet sun 0.1 dry sun0.9 wet rain 0.7

8

ProbabilityRecap§ Conditionalprobability

§ Productrule

§ Chainrule

§ Bayesrule

§ X,Yindependentifandonlyif:

§ XandYareconditionallyindependentgivenZ:ifandonlyif: