libDirectioal
libDirectioalisalibraryfordirectioalstatisticsaswellasrecursiveestimatioodirectioalmaifolds.Thesupportedmaifoldsiclude
uitcircleuithyperspherecomplexuithyperspheretorusSE(2)Foreachofthesemaifolds,thelibrarycotaiscertaiprobabilitydistributiosaswellasrecursivefilterigalgorithms.
IstallatioRequiremets:
Matlab2021aorlaterasuitablecompiler(VisualStudio2015,VisualStudio2017,MiGW64,gcc4.7orlater,XCode)TouselibDirectioal,addtheetirelib-foldericludigsubdirectoriestoMatlab'ssearchpath.The,chagetothelib-folderadruthecompileAll.mscript.Thisscriptshouldcompileallmex-filesusedbylibDirectioal.
Ifyouexperieceayissues,rumex-setupadmex-setupC++toesurethatyouhaveselectedthecorrectcompiler.Icaseyouhavetroublecompiligwithgcc,makesurethatyouareusigaversiothatisofficiallysupportedbyMATLAB.
ThefollowigtoolboxesarerecommededforlibDirectioal:
image_toolboxoptimizatio_toolboxstatistics_toolboxsymbolic_toolboxThestatisticstoolboxadtheoptimizatiotoolboxarefairlywidelyused,buttheothertoolboxesareolyrequiredforcertaiveryspecificfeatures.
Example:PlottigProbabilityDesityFuctiosForexample,wecageerateatwo-dimesioalplotofthepdfofawrappedormaldistributiowithparametersmu=2adsigma=1.3simplybytypigthefollowigtwocommads.
>>w=WNDistributio(2,1.3);>>w.plot2d();Wecathesetthelabelsadaxisusigthefollowigcode:
>>setupAxisCircular('x');>>xlabel('x');ylabel('f(x)');Similarly,wecacreateplotsofotherdistributios.Athree-dimesioalplotofthepdfofavoMisesdistributiowithparametersmu=6adkappa=0.5couldbegeeratedusigthefollowigcode.
>>vm=VMDistributio(6,0.5);>>vm.plot3d('color','red');>>holdo;vm.plotCircle('color','black');holdoff;>>xlabel('cos(x)');ylabel('si(x)');zlabel('f(x)');Example:NumericaladAalyticalCalculatioLetusagaicosiderthewrappedormaldistributiodefiedithepreviousexample.Supposewewattocalculatethefirsttrigoometricmomet,i.e.,E(exp(ix)),ofthisdistributio.Forthispurpose,wesimplycallthecorrespodigfuctio:
>>w.trigoometricMomet(1)Thisproducestheoutput
as=-0.1788+0.3906iIthecaseofthewrappedormaldistributio,trigoometricMometisafuctioisidetheclassWNDistributiothatimplemetsaaalyticcalculatioofthetrigoometricmomet.Ifoaalyticsolutiowasimplemeted,thefuctiotrigoometricMometithebaseclassAbstractCircularDistributiowouldautomaticallyfallbacktoaalgorithmbasedoumericalitegratio.Evethoughaaalyticalsolutioisavailableforthewrappedormaldistributio,wecastillcalltheumericalalgorithmasfollows.
>>w.trigoometricMometNumerical(1)Weobtaitheresult
as=-0.1788+0.3906iThisca,forexample,beusedtocomparetheumericaladaalyticalresultsiordertoesurecorrectessoftheaalyticalimplemetatio.Ithiscase,bothresultsmatchuptothedisplayedumberofdigits,buticertaicases,aalyticaladumericalsolutiosmaydiffermoresigificatly.
Example:NoliearCircularFilterigLetuscosiderasystemwithcircularstatex_ki[0,2pi)addyamics
x_{k+1}=a(x_k)+w_ka_k(x_k)=x+0.1cos(x_k)mod2piwherew_kisdistributedaccordigtoWN(x;0,0.4)IfweassumethatthecurretstateisdistributedaccordigtoWN(x;2,0.5),wecaperformthepredictiostepwiththeWN-assumedfilterusigthefollowigcommads.
>>filter=WNFilter();>>filter.setState(WNDistributio(2,0.5));>>a=@(x)mod(x+0.1*cos(x),2*pi);>>filter.predictNoliear(a,WNDistributio(0,0.4));>>filter.getEstimate()Thisproducestheoutput
as=WNDistributiowithproperties:mu:1.9623sigma:0.6092Asyoucasee,thepredicteddesityisreturedasawrappedormaldistributio.Nowwecosiderthemeasuremetmodel
z_k=h_k(x_k)+v_kwith
h_k:[0,2pi)->R,h_k(x)=si(x)wherev_kisadditiveoisedistributedaccordigtoN(x;0,0.7).Asyoucasee,wehaveacircularstate,butareal-valuedmeasuremet,ithiscase.However,acircularmeasuremet(orameasuremetoacompletelydifferetmaifold)wouldbepossibleaswell.Ifweobtaiameasuremet,sayz=0.3,wecaperformthemeasuremetupdateasfollows.
>>h=@(x)si(x);>>measuremetNoise=GaussiaDistributio(0,0.7);>>likelihood=LikelihoodFactory.additiveNoiseLikelihood(h,measuremetNoise);>>filter.updateNoliearProgressive(likelihood,0.3)>>filter.getEstimate()Thisproducestheoutput
as=WNDistributiowithproperties:mu:2.0030sigma:0.6414Oceagai,weobtaitheresultasawrappedormaldistributio.
UitTestsTheuittestsforlibDirectioalarelocatedithetestssubfolder.YoucaautomaticallyrualluittestsbyexecutigruLibDirectioalUitTests.Teststhatareverycomputatioallyexpesiveareskippedbydefault.YoucaeablecomputatioallyexpesivetestsbyruigruLibDirectioalUitTests(true),whichismorethoroughbuttakesmuchmoretime.
ExteralslibDrectioalreliesothefollowigexterallibraries,whicharealsoicludeditheexteralsfolder.
Eige(MPL2)fmath(BSD)mhg(GLPv2orlater)Faddeva(MIT)NoliearEstimatioToolbox(GPLv3),olytheecessarysubsetisicludediexteralsfolderTesselateS3(GPLv3)ModifiedversiosofSlepiaAlphaadSlepiaBravo(GPLv2orlater)Wiger3j(BSD)AmodifiedversiooftheRecursiveZoalEqualAreaSpherePartitioigToolbox(MIT)Furthermore,weusethescriptcircVMcdfbyShaiRevze(GPLv3).WealsousesomecodefromlibBigham(BSD),butthislibraryisotitheexteralsfolderasolysmallpartsareused.
LiceselibDirectioalislicesedudertheGPLv3licese.
CitatioIfyouuselibDirectioaliyourresearch,pleasecitethelibraryusigasfollows.
@Article{libdirectioal,author={GerhardKurzadIgorGilitscheskiadFloriaPfaffadLukasDrudeadUweD.HaebeckadReiholdHaeb-UmbachadRoladY.Siegwart},title={DirectioalStatisticsadFilterigUsig{libDirectioal}},year={2019},joural={JouralofStatisticalSoftware},volume={89},umber={4},pages={1--31},doi={10.18637/jss.v089.i04},}CotactLeadauthor:GerhardKurz
Mail:kurz.gerhard(at)gmail.com
Web:https://www.gerhardkurz.de
Cotributors:
IgorGilitscheskiFloriaPfaffLukasDrude
评论