mldivide是否始终与MATLAB中的OLS相同? [英] Is mldivide always the same as OLS in MATLAB?

查看:68
本文介绍了mldivide是否始终与MATLAB中的OLS相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在比较一些替代的线性回归技术.

I am doing a comparison of some alternate linear regression techniques.

显然,相对于OLS(普通最小二乘),这些标记将成为基准.

Clearly these will be bench-marked relative to OLS (Ordinary Least Squares).

但是我只想使用一种纯粹的OLS方法,而无需对数据进行预处理就可以发现使用regress()时发现的数据中的不良情况.

But I just want a pure OLS method, no preconditioning of the data to uncover ill-conditioning in the data as you find when you use regress().

我曾希望简单地使用经典的(XX)^-1XY表达式?但这需要使用inv()函数,但是在inv()的MATLAB指南页中,建议您在进行最小二乘估计时使用mldivide,因为它在执行时间和数值精度方面都比较好.

I had hoped to simply use the classic (XX)^-1XY expression? However this would necessitate using the inv() function, but in the MATLAB guide page for inv() it recommends that you use mldivide when doing least squares estimation as it is superior in terms of execution time and numerical accuracy.

但是,我担心使用mldivide查找OLS估计是否可以?作为操作员,似乎无法通过在调试器中单步执行"来了解该功能的作用.

However, I'm concerned as to whether it's okay to use mldivide to find the OLS estimates? As an operator it seems I can't see what the function is doing by "stepping-in" in the debugger.

我是否可以假定mldivide在所有条件下(包括存在奇异/i-ll条件矩阵)都会产生与理论OLS相同的答案?

Can I be assume that mldivide will produce the same answers as theoretical OLS under all conditions (including in the presence of) singular/i-ll conditioned matrices)?

如果不是,在没有任何数据预处理的情况下,在MATLAB中计算纯OLS答案的最佳方法是什么?

If not what is the best way to compute pure OLS answers in MATLAB without any preconditioning of the data?

推荐答案

当系统A*x = b被超定时,两种算法都提供相同的答案.当系统不确定时,PINV将返回具有最小范数(最小NORM(x))的解决方案x. MLDIVIDE将选择具有最少非零元素数量的解决方案.

When the system A*x = b is overdetermined, both algorithms provide the same answer. When the system is underdetermined, PINV will return the solution x, that has the minimum norm (min NORM(x)). MLDIVIDE will pick the solution with least number of non-zero elements.

关于mldivide的工作方式,但是,您可能还想看看此答案,这是有关相对于矩阵A为正方形的其他方法.

However, you might also want to have a look at this answer for the first part of the discussion about mldivide vs. other methods when the matrix A is square.

根据矩阵的形状和组成,您可以将Cholesky分解用于对称正定,将LU分解用于其他方矩阵,或者将QR用于其他方式.然后,您可以保留因式分解并使用linsolve基本上只是为您做反替换.

Depending on the shape and composition of the matrix you would use either Cholesky decomposition for symmetric positive definite, LU decomposition for other square matrix or QR otherwise. Then you can can hold onto the factorization and use linsolve to essentially just do back-substitution for you.

A不是正方形(过度指定)或不是正方形而是单数时,mldivide是否比pinv更可取,

As to whether mldivide is preferable to pinv when A is either not square (overspecified) or is square but singular, the two options will give you two of the infinitely many solutions. According to those docs, both solutions will give you exact solutions:

norm(A*x-b)norm(A*y-b)处于舍入误差的顺序的意义上讲,这两者都是精确的解决方案.

Both of these are exact solutions in the sense that norm(A*x-b) and norm(A*y-b)are on the order of roundoff error.

这篇关于mldivide是否始终与MATLAB中的OLS相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆