matlab关于矩阵分解和变换的常用命令介绍

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

+ReviewofLinearAlgebraIntroductiontoMatlabMachineLearningGroupFall2014+OutlineLinearAlgebraBasicsMatrixCalculusSingularValueDecomposition(SVD)EigenvalueDecompositionLow-rankMatrixInversionMatlabessentialsBasicconceptsVectorinRnisanorderedsetofnrealnumbers.e.g.v=(1,6,3,4)isinR4Acolumnvector:Arowvector:m-by-nmatrixisanobjectinRmxnwithmrowsandncolumns,eachentryfilledwitha(typically)realnumber:436143612396784821BasicconceptsVectornorms:Anormofavector||x||isinformallyameasureofthe“length”ofthevector.–Commonnorms:L1,L2(Euclidean)–LinfinityBasicconceptsVectordot(inner)product:Vectorouterproduct:WewilluselowercaselettersforvectorsTheelementsarereferredbyxi.Ifu•v=0,||u||2!=0,||v||2!=0uandvareorthogonalIfu•v=0,||u||2=1,||v||2=1uandvareorthonormalBasicconceptsMatrixproduct:222212212122112122121211211211112221121122211211,babababababababaABbbbbBaaaaAWewilluseuppercaselettersformatrices.TheelementsarereferredbyAi,j.e.g.Specialmatricesfedcba000cba000000jihgfedcba000000fedcba000diagonalupper-triangulartri-diagonallower-triangular100010001I(identitymatrix)BasicconceptsTranspose:Youcanthinkofitas“flipping”therowsandcolumnsOR“reflecting”vector/matrixonlinebabaTdbcadcbaTe.g.+Linearindependence000||||||321321cccvvv(u,v)=(0,0),i.e.thecolumnsarelinearlyindependent.•Asetofvectorsislinearlyindependentifnoneofthemcanbewrittenasalinearcombinationoftheothers.•Vectorsv1,…,vkarelinearlyindependentifc1v1+…+ckvk=0impliesc1=…=ck=0000313201vue.g.x3=−2x1+x2+Spanofavectorspace•Ifallvectorsinavectorspacemaybeexpressedaslinearcombinationsofasetofvectorsv1,…,vk,thenv1,…,vkspansthespace.•Thecardinalityofthissetisthedimensionofthevectorspace.•Abasisisamaximalsetoflinearlyindependentvectorsandaminimalsetofspanningvectorsofavectorspace100201020012222(0,0,1)(0,1,0)(1,0,0)e.g.+RankofaMatrixrank(A)(therankofam-by-nmatrixA)isThemaximalnumberoflinearlyindependentcolumns=Themaximalnumberoflinearlyindependentrows=Thedimensionofcol(A)=Thedimensionofrow(A)IfAisnbym,thenrank(A)=min(m,n)Ifn=rank(A),thenAhasfullrowrankIfm=rank(A),thenAhasfullcolumnrank+InverseofamatrixInverseofasquarematrixA,denotedbyA-1istheuniquematrixs.t.AA-1=A-1A=I(identitymatrix)IfA-1andB-1exist,then(AB)-1=B-1A-1,(AT)-1=(A-1)TFororthonormalmatricesFordiagonalmatrices+DimensionsByThomasMinka.OldandNewMatrixAlgebraUsefulforStatistics+Examples(SVD)AnymatrixAcanbedecomposedasA=UDVT,whereDisadiagonalmatrix,withd=rank(A)non-zeroelementsThefistdrowsofUareorthogonalbasisforcol(A)ThefistdrowsofVareorthogonalbasisforrow(A)ApplicationsoftheSVDMatrixPseudoinverseLow-rankmatrixapproximation+EigenValueDecompositionAnysymmetricmatrixAcanbedecomposedasA=UDUT,whereDisdiagonal,withd=rank(A)non-zeroelementsThefistdrowsofUareorthogonalbasisforcol(A)=row(A)Re-interpretingAbFirststretchbalongthedirectionofu1byd1timesThenfurtherstretchitalongthedirectionofu2byd2times+Low-rankMatrixInversionInmanyapplications(e.g.linearregression,Gaussianmodel)weneedtocalculatetheinverseofcovariancematrixXTX(eachrowofn-by-mmatrixXisadatasample)Ifthenumberoffeaturesishuge(e.g.eachsampleisanimage,#samplen#featurem)invertingthem-by-mXTXmatrixbecomesanproblemComplexityofmatrixinversionisgenerallyO(n3)Matlabcancomfortablysolvematrixinversionwithm=thousands,butnotmuchmorethanthat+Low-rankMatrixInversionWiththehelpofSVD,weactuallydoNOTneedtoexplicitlyinvertXTXDecomposeX=UDVTThenXTX=VDUTUDVT=VD2VTSinceV(D2)VTV(D2)-1VT=IWeknowthat(XTX)-1=V(D2)-1VTInvertingadiagonalmatrixD2istrivial+BasicsDerivativesDecompositionsDistributions…+MATrixLABoratoryMostlyusedformathematicallibrariesVeryeasytodomatrixmanipulationinMatlabIfthisisyourfirsttimeusingMatlabStronglysuggestyougothroughthe“GettingStarted”partofMatlabhelpManyusefulbasicsyntax+MakingArrays%Asimplearray[12345]ans:12345[1,2,3,4,5]ans:12345v=[1;2;3;4;5]v=12345v’ans:123451:5ans:123451:2:5ans:1355:-2:1ans:531rand(3,1)ans:0.03180.27690.0462+MakingMatrices%Allthefollowingareequivalent[123;456;789][1,2,3;4,5,6;7,8,9][[12;45;78][3;6;9]][[123;456];[789]]ans:123456789+MakingMatrices%Creatingallones,zeros,identity,diagonalmatriceszeros(rows,cols)ones(rows,cols)eye(rows)diag([123])%CreatingRandommatricesrand(rows,cols)%Unif[0,1]randn(rows,cols)%N(0,1)%Make3x5withN(1,4)entries2*randn(3,5)+1%Getthesize[rows,cols]=size(matrix);+AccessingElementsUnlikeC-likelanguages,indicesstartfrom1(NOT0)A=[123;456;789]ans:123456789%AccessIndividualElementsA(2,3)ans:6%Access2ndcolumn(:meansallelements)A(:,2)ans:258+AccessingElementsA=123456789Matlabhascolumn-orderA([1,3,5])ans:175A([1,3],2:end)ans:2389A(A5)=-1ans:12345-1-1-1-1A(A5)=-1ans:7869[ij]=find(A5)i=3j=1322333+MatrixOperatio

1 / 28
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功