libDirectional开源项目

我要开发同款
匿名用户2021年11月23日
46阅读
所属分类、应用工具、科研计算工具
授权协议GPL-3.0 License

作品详情

libDirectional

libDirectionalisalibraryfordirectionalstatisticsaswellasrecursiveestimationondirectionalmanifolds.Thesupportedmanifoldsinclude

unitcircleunithyperspherecomplexunithyperspheretorusSE(2)

Foreachofthesemanifolds,thelibrarycontainscertainprobabilitydistributionsaswellasrecursivefilteringalgorithms.

Installation

Requirements:

Matlab2021aorlaterasuitablecompiler(VisualStudio2015,VisualStudio2017,MinGW64,gcc4.7orlater,XCode)

TouselibDirectional,addtheentirelib-folderincludingsubdirectoriestoMatlab'ssearchpath.Then,changetothelib-folderandrunthecompileAll.mscript.Thisscriptshouldcompileallmex-filesusedbylibDirectional.

Ifyouexperienceanyissues,runmex-setupandmex-setupC++toensurethatyouhaveselectedthecorrectcompiler.Incaseyouhavetroublecompilingwithgcc,makesurethatyouareusingaversionthatisofficiallysupportedbyMATLAB.

ThefollowingtoolboxesarerecommendedforlibDirectional:

image_toolboxoptimization_toolboxstatistics_toolboxsymbolic_toolbox

Thestatisticstoolboxandtheoptimizationtoolboxarefairlywidelyused,buttheothertoolboxesareonlyrequiredforcertainveryspecificfeatures.

Example:PlottingProbabilityDensityFunctions

Forexample,wecangenerateatwo-dimensionalplotofthepdfofawrappednormaldistributionwithparametersmu=2andsigma=1.3simplybytypingthefollowingtwocommands.

>>wn=WNDistribution(2,1.3);>>wn.plot2d();

Wecanthensetthelabelsandaxisusingthefollowingcode:

>>setupAxisCircular('x');>>xlabel('x');ylabel('f(x)');

Similarly,wecancreateplotsofotherdistributions.Athree-dimensionalplotofthepdfofavonMisesdistributionwithparametersmu=6andkappa=0.5couldbegeneratedusingthefollowingcode.

>>vm=VMDistribution(6,0.5);>>vm.plot3d('color','red');>>holdon;vm.plotCircle('color','black');holdoff;>>xlabel('cos(x)');ylabel('sin(x)');zlabel('f(x)');Example:NumericalandAnalyticalCalculation

Letusagainconsiderthewrappednormaldistributiondefinedinthepreviousexample.Supposewewanttocalculatethefirsttrigonometricmoment,i.e.,E(exp(ix)),ofthisdistribution.Forthispurpose,wesimplycallthecorrespondingfunction:

>>wn.trigonometricMoment(1)

Thisproducestheoutput

ans=-0.1788+0.3906i

Inthecaseofthewrappednormaldistribution,trigonometricMomentisafunctioninsidetheclassWNDistributionthatimplementsananalyticcalculationofthetrigonometricmoment.Ifnoanalyticsolutionwasimplemented,thefunctiontrigonometricMomentinthebaseclassAbstractCircularDistributionwouldautomaticallyfallbacktoanalgorithmbasedonnumericalintegration.Eventhoughananalyticalsolutionisavailableforthewrappednormaldistribution,wecanstillcallthenumericalalgorithmasfollows.

>>wn.trigonometricMomentNumerical(1)

Weobtaintheresult

ans=-0.1788+0.3906i

Thiscan,forexample,beusedtocomparethenumericalandanalyticalresultsinordertoensurecorrectnessoftheanalyticalimplementation.Inthiscase,bothresultsmatchuptothedisplayednumberofdigits,butincertaincases,analyticalandnumericalsolutionsmaydiffermoresignificantly.

Example:NonlinearCircularFiltering

Letusconsiderasystemwithcircularstatex_kin[0,2pi)anddynamics

x_{k+1}=a(x_k)+w_ka_k(x_k)=x+0.1cos(x_k)mod2pi

wherew_kisdistributedaccordingtoWN(x;0,0.4)IfweassumethatthecurrentstateisdistributedaccordingtoWN(x;2,0.5),wecanperformthepredictionstepwiththeWN-assumedfilterusingthefollowingcommands.

>>filter=WNFilter();>>filter.setState(WNDistribution(2,0.5));>>a=@(x)mod(x+0.1*cos(x),2*pi);>>filter.predictNonlinear(a,WNDistribution(0,0.4));>>filter.getEstimate()

Thisproducestheoutput

ans=WNDistributionwithproperties:mu:1.9623sigma:0.6092

Asyoucansee,thepredicteddensityisreturnedasawrappednormaldistribution.Nowweconsiderthemeasurementmodel

z_k=h_k(x_k)+v_k

with

h_k:[0,2pi)->R,h_k(x)=sin(x)

wherev_kisadditivenoisedistributedaccordingtoN(x;0,0.7).Asyoucansee,wehaveacircularstate,butareal-valuedmeasurement,inthiscase.However,acircularmeasurement(orameasurementonacompletelydifferentmanifold)wouldbepossibleaswell.Ifweobtainameasurement,sayz=0.3,wecanperformthemeasurementupdateasfollows.

>>h=@(x)sin(x);>>measurementNoise=GaussianDistribution(0,0.7);>>likelihood=LikelihoodFactory.additiveNoiseLikelihood(h,measurementNoise);>>filter.updateNonlinearProgressive(likelihood,0.3)>>filter.getEstimate()

Thisproducestheoutput

ans=WNDistributionwithproperties:mu:2.0030sigma:0.6414

Onceagain,weobtaintheresultasawrappednormaldistribution.

UnitTests

TheunittestsforlibDirectionalarelocatedinthetestssubfolder.YoucanautomaticallyrunallunittestsbyexecutingrunLibDirectionalUnitTests.Teststhatareverycomputationallyexpensiveareskippedbydefault.YoucanenablecomputationallyexpensivetestsbyrunningrunLibDirectionalUnitTests(true),whichismorethoroughbuttakesmuchmoretime.

Externals

libDrectionalreliesonthefollowingexternallibraries,whicharealsoincludedintheexternalsfolder.

Eigen(MPL2)fmath(BSD)mhg(GLPv2orlater)Faddeva(MIT)NonlinearEstimationToolbox(GPLv3),onlythenecessarysubsetisincludedinexternalsfolderTesselateS3(GPLv3)ModifiedversionsofSlepianAlphaandSlepianBravo(GPLv2orlater)Wigner3j(BSD)AmodifiedversionoftheRecursiveZonalEqualAreaSpherePartitioningToolbox(MIT)

Furthermore,weusethescriptcircVMcdfbyShaiRevzen(GPLv3).WealsousesomecodefromlibBingham(BSD),butthislibraryisnotintheexternalsfolderasonlysmallpartsareused.

License

libDirectionalislicensedundertheGPLv3license.

Citation

IfyouuselibDirectionalinyourresearch,pleasecitethelibraryusingasfollows.

@Article{libdirectional,author={GerhardKurzandIgorGilitschenskiandFlorianPfaffandLukasDrudeandUweD.HanebeckandReinholdHaeb-UmbachandRolandY.Siegwart},title={DirectionalStatisticsandFilteringUsing{libDirectional}},year={2019},journal={JournalofStatisticalSoftware},volume={89},number={4},pages={1--31},doi={10.18637/jss.v089.i04},}Contact

Leadauthor:GerhardKurz

Mail:kurz.gerhard(at)gmail.com

Web:https://www.gerhardkurz.de

Contributors:

IgorGilitschenskiFlorianPfaffLukasDrude
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论