资源描述:
《think bayes two dimensions》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、CHAPTER9TwoDimensionsPaintballPaintballisasportinwhichcompetingteamstrytoshooteachotherwithgunsthatfirepaint-filledpelletsthatbreakonimpact,leavingacolorfulmarkonthetarget.Itisusuallyplayedinanarenadecoratedwithbarriersandotherobjectsthatcanbeusedascover.Supposeyouareplayingpaintballinanindoorare
2、na30feetwideand50feetlong.Youarestandingnearoneofthe30footwalls,andyoususpectthatoneofyouropponentshastakencovernearby.Alongthewall,youseeseveralpaintspatters,allthesamecolor,thatyouthinkyouropponentfiredrecently.Thespattersareat15,16,18,and21feet,measuredfromthelower-leftcorneroftheroom.Basedont
3、hesedata,wheredoyouthinkyouropponentishiding?Figure9-1showsadiagramofthearena.Usingthelower-leftcorneroftheroomastheorigin,Idenotetheunknownlocationoftheshooterwithcoordinatesαandβ,oralphaandbeta.Thelocationofaspatterislabeledx.Theangletheopponentshootsatisθortheta.ThePaintballproblemisamodifiedv
4、ersionoftheLighthouseproblem,acommonexampleofBayesiananalysis.MynotationfollowsthepresentationoftheprobleminD.S.Sivia’s,DataAnalysis:aBayesianTutorial,SecondEdition(Oxford,2006).Youcandownloadthecodeinthischapterfromhttp://thinkbayes.com/paintball.py.Formoreinformationsee“Workingwiththecode”onpag
5、exi.ThesuiteTogetstarted,weneedaSuitethatrepresentsasetofhypothesesaboutthelocationoftheopponent.Eachhypothesisisapairofcoordinates:(alpha,beta).93Figure9-1.Diagramofthelayoutforthepaintballproblem.HereisthedefinitionofthePaintballsuite:classPaintball(thinkbayes.Suite,thinkbayes.Joint):def__init_
6、_(self,alphas,betas,locations):self.locations=locationspairs=[(alpha,beta)foralphainalphasforbetainbetas]thinkbayes.Suite.__init__(self,pairs)PaintballinheritsfromSuite,whichwehaveseenbefore,andJoint,whichIwillexplainsoon.alphasisthelistofpossiblevaluesforalpha;betasisthelistofvaluesforbeta.pairs
7、isalistofall(alpha,beta)pairs.locationsisalistofpossiblelocationsalongthewall;itisstoredforuseinLikelihood.Theroomis30feetwideand50feetlong,sohere’sthecodethatcreatesthesuite:alphas=range(0,31)betas=range(1,51)location