主要内容

svdsketch

Compute SVD of low-rank matrix sketch

描述

例子

[S.V.] = svdsketch(一种的)returns the singular value decomposition (SVD) of a low-rank matrix sketch of input matrix一种。The matrix sketch is a low-rank approximation that only reflects the most important features of一种(达到公差),与使用相比,这使得能够更快地计算大矩阵的部分SVDsvds

例子

[S.V.] = svdsketch(一种的)指定矩阵草图的公差。svdsketch用途自适应地确定矩阵草图近似的等级。随着宽容变得更大,功能较少一种用于矩阵素描。

例子

[S.V.] = svdsketch(一种名称,价值的)指定具有一个或多个的其他选项名称,价值对论点。例如,您可以指定'发光'和标量来调整用于形成矩阵草图的迭代次数。

例子

[S.V.apxErr] = svdsketch(___的)additionally returns a vectorapxErr其中包含每次迭代中的相对近似误差,常态(U * s * v'-a,'fro')/ norm(a,'fro')。The final entry in the vectorAPXERR(END)是返回的输出的相对近似误差svdsketch

例子

全部收缩

采用svdsketch计算低秩矩阵近似的SVD因子。

采用画廊创建一个200×200个随机矩阵,具有几何分布式奇异值。

a =画廊('randsvd',200);

采用svdsketch计算低秩近似的SVD一种

[u,s,v] = svdsketch(a);

检查输出的大小。

尺寸
ANS =.1×2120 120.

结果表明低秩矩阵近似一种排名120。

S.pecify a tolerance withsvdsketch计算低秩矩阵近似的SVD因子。svdsketch基于指定的公差,自适应地确定矩阵草图的适当等级。

采用画廊创建一个200×200个随机矩阵,具有几何分布式奇异值。

a =画廊('randsvd',200);

采用svdsketch为了计算A的低秩近似的SVD。指定宽度1E-2那and find the size of the outputS.确定等级svdsketch用于矩阵草图。

tol = 1e-2;[u,s,v] = svdsketch(a,tol);尺寸
ANS =.1×260 60.

结果表明低秩矩阵近似一种排名60。

检查矩阵草图的近似程度如何一种通过比较一种T.O.你*S*V'

常态(U * s * v' -  a,'fro'/ qu(a,'fro'的)
ANS =.0.。0.0.48

结果表明矩阵草图近似一种within the specified tolerance of1E-2

采用svdsketchwith themaxsubacedimension.O.ption on a matrix that has slowly decaying singular values. You can use this option to forcesvdsketch使用特征的子集一种在矩阵素描中。

Create a 5000-by-5000 matrix with values drawn from the standard normal distribution. View the distribution of matrix singular values.

a = randn(5000);半机(SVD(A),'-o'的)

图包含轴对象。轴对象包含类型线的对象。

自从T.he singular values in一种腐烂慢,一种has many important features and does not lend itself to low-rank approximations. To form a matrix sketch that reasonably approximates一种那most or nearly all of the features need to be preserved.

采用svdsketch在具有容差的基质上1E-5。指定四个输出以返回SVD因子以及每次迭代中的相对近似误差。

托=1E-5; [U1,S1,V1,apxError1] = svdsketch(A,tol); size(S1)
ANS =.1×25000 5000

的大小S.表示满足容差,svdsketch需要保留所有特征一种。对于大稀疏输入矩阵,这可以在低级近似以来呈现内存问题一种svdsketch大致相同一种因此可能不适合记忆作为密集的矩阵。

检查输出的近似误差。自从svdsketch保留一切一种那T.he computed answer is accurate, but the calculation was just an expensive way to calculatesvd(x)

APXError1(结束)
ANS = 1.2362E-07

Now, do the same calculation but specifymaxsubacedimension.as 650 to limit the size of the subspace used to sketch一种。这对于迫使这很有用svdsketch仅使用功能的子集一种要形成矩阵素描,请降低输出的大小。

[你2那S.2那V.2那apxError2] = svdsketch(A,tol,'maxsubspacedimension'那650); size(S2)
ANS =.1×2650 650.

输出现在具有较小的尺寸。

检查新输出的近似误差。强制输出较小的权衡是在矩阵草图中需要省略许多重要特征,并得到的秩650近似一种不符合指定的公差。

APXError2(结束)
ANS = 0.8214

输入参数

全部收缩

输入矩阵那specified as a sparse or full matrix.一种通常,但并不总是,庞大且稀疏的矩阵。svdsketchis best suited to operate on rank-deficient matrices that have a relatively small number of features.

数据类型:single|双倍的
复数支持:金宝app是的

矩阵素描公差那specified as a real numeric scalar in the rangeSQRT(EPS(ACS(A)))<= tol <1

svdsketch用途T.he value of自适应地确定哪些特征一种T.O.use in the low-rank approximation (matrix sketch) of一种。一种s the value of增加,svdsketch用途fewer features of一种形成矩阵草图。

例子:[u,s,v] = svdsketch(a,1e-4)

数据类型:single|双倍的

名称 - 值参数

S.pecify optional pairs of arguments asName1=Value1,...,NameN=ValueN, 在哪里Name是参数名称和V.alue是相应的价值。名称 - 值参数必须在其他参数之后出现,但对的顺序无关紧要。

B.E.fore R2021a, use commas to separate each name and value, and encloseName在报价中。

例子:[u,s,v] = svdsketch(a,1e-10,'maxtations',100)使用100个迭代svdsketch算法。

最大子空间尺寸,指定为正整数标量。子空间尺寸控制内存消耗svdsketch算法。如果算法运行在指定公差的内存中,则可以指定较小的值maxsubacedimension.因此,算法保持内存。例如,调整此参数可能是有用的一种有奇异值慢慢衰减。

当您指定时maxsubacedimension.选项,您可以在使用的矩阵草图的等级设置最大值svdsketch。因此,如果svdsketch不能满足小于的秩的指定公差maxsubacedimension.那it uses the maximum allowed rank, and the resulting outputs might not satisfy the specified tolerance.

例子:[你那S.那V.] = svdsketch(一种那1E.-7,'MaxSubspaceDimension',150)

数据类型:single|双倍的

初始算法块大小,指定为正整数标量。块大小是矩阵草图的等级增加每次迭代的数量。较大的块大小通过每次迭代做更多工作来减少所需的迭代次数,但也可能在计算的计算中添加更多信息,而不是实现收敛。

一种s the algorithm proceeds,svdsketch如果相对近似误差,可能会从初始值调整块大小以加速会聚apxErr没有足够的腐烂。

如果you specifyB.L.O.ckSize,该值应小于maxsubacedimension.

例子:[你那S.那V.] = svdsketch(一种那1E.-7,'BlockSize',10)

数据类型:single|双倍的

最大算法迭代次数,指定为正整数标量。更多的迭代可以以更高的执行时间和更高的内存消耗产生更高质量的矩阵草图。

例子:[你那S.那V.] = svdsketch(一种那1E.-7,'MaxIterations',25)

数据类型:single|双倍的

功率迭代的数量,指定为非负整数标量。权力迭代提高了正交性andV.输出。您通常应该选择要的功率迭代次数0.1那O.r2那as larger values can adversely contribute to round-off error.

例子:[u,s,v] = svdsketch(a,1e-7,'numpower杂志',2)

数据类型:single|双倍的

输出参数

全部收缩

Left singular vectors of matrix sketch, returned as a matrix. The columns ofare orthonormal, and they form a set of basis vectors for the range of the matrix sketch of一种

的大小取决于价值。一种s变大,svdsketch使用较少的输入矩阵的功能来形成矩阵素描,因此andV.也有更少的列。

Different machines and releases of MATLAB®可以产生仍然是数值准确的不同奇异载体。相应的列andV.can flip their signs, since this does not affect the value of the expressiona = u * s * v'

S.ingular values of matrix sketch, returned as a square diagonal matrix. The diagonal elements ofS.是矩阵素描的严格正奇值,以减少顺序。

的大小S.取决于价值。一种s the tolerance increases,svdsketch使用较少的输入矩阵的功能来形成矩阵素描,因此S.相应较少的行和列。

矩阵素描的右奇异载体,作为矩阵返回。列的列V.是正常的,它们形成了一组基础矢量,用于矩阵素描的零空格一种

的大小V.取决于价值。一种s变大,svdsketch使用较少的输入矩阵的功能来形成矩阵素描,因此andV.也有更少的列。

Different machines and releases of MATLAB can produce different singular vectors that are still numerically accurate. Corresponding columns inandV.can flip their signs, since this does not affect the value of the expressiona = u * s * v'

Relative approximation error in each iteration, returned as a vector. The length ofapxErris equal to the number of iterations used in thesvdsketch算法。采用最大调整迭代次数。

参赛作品apxErrare the relative approximation errors in each iteration,常态(U * s * v'-a,'fro')/ norm(a,'fro')。The final entry in the vectorAPXERR(END)是返回的输出的相对近似误差svdsketch

尖端

  • 采用svdsketch当你提前不了解的时候,排名是指定的svds,但你知道SVD的近似应该满足的容忍度。

  • svds计算SVD的最佳等级-K近似值(使用默认值"largest"方法)。svdsketch不保证其等级-k近似是最好的,这是它的速度优势svds

一种L.gorithms

svdsketchapplies a tolerance to form a low-rank matrix approximation 一种 问: B. 输入矩阵一种。这种低级近似称为a矩阵sketch。矩阵素描只能保留重要的功能一种,过滤不必要的信息。相对近似误差apxErr矩阵素描旨在满足指定的公差

E. sketch = 问: B. 一种 F 一种 F T. O. L.

这个过程svdsketch遵循以形成矩阵素描是:

  • svdsketch迭代地形成矩阵草图,每次迭代都会添加新列问:and new rows toB.。The new columns and rows are created by extracting features from一种使用随机样本矩阵。您可以控制每个迭代中添加的列和行数B.L.O.ckSize名称值对。

  • During each iteration,svdsketch使用电源迭代来改善新列的正交性问:。You can adjust the number of power iterations with thenumpower杂志名称值对。

  • 迭代以形成矩阵素描停止时间:列中的列数问:和行B.reach the specified value formaxsubacedimension.,迭代的数量达到最大那O.r the relative approximation error converges (apxErr <= tol)。

  • 提高收敛速度,svdsketchmight increase the specified initial value forB.L.O.ckSize从迭代到迭代如果衰退apxErris not sufficient.

在矩阵素描之后 一种 问: B. 形成了,svdsketch计算奇异值分解)T.he matrix sketch via[U1,S,V] = SVD(B,'ECON')那such that

一种 问: B. = 问: 1 的) S. V. H = S. V. H

如果svdsketch能够过滤掉一些功能一种based on the specified tolerance, then the resulting SVD factors contain fewer singular values and singular vectors than if a full SVD was performed on一种

参考

[1]余,文主,余谷,姚明李。“有效的随机算法,用于固定精度低级矩阵近似。”矩阵分析与应用中的暹罗39, no. 3 (August 2018): 1339–1359.https://doi.org/10.1137/17M1141977

扩展能力

版本历史记录

在R2020B中介绍