cse 473: artificial intelligence topics from 30,000’ probability we · 2017-05-05 · 5 the...
TRANSCRIPT
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
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)
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)?
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
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
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)]
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
8
ProbabilityRecap§ Conditionalprobability
§ Productrule
§ Chainrule
§ Bayesrule
§ X,Yindependentifandonlyif:
§ XandYareconditionallyindependentgivenZ:ifandonlyif: