最小化MATLAB中公式的误差(最小二乘?) [英] Minimizing error of a formula in MATLAB (Least squares?)

查看:451
本文介绍了最小化MATLAB中公式的误差(最小二乘?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对MATLAB或计算数学不太熟悉,所以我想知道如何求解一个包含平方和的方程,其中每个项都涉及两个向量-一个已知和一个未知.该公式应该代表错误,我需要将错误最小化.我想我应该使用最小二乘,但对此我不太了解,我想知道哪种函数最适合这样做,什么参数可以代表我的方程式.我的老师还提到了一些关于使用导数的事情,他使用导数形成了一个矩阵,这使我更加困惑-我是否需要使用导数?

I'm not too familiar with MATLAB or computational mathematics so I was wondering how I might solve an equation involving the sum of squares, where each term involves two vectors- one known and one unknown. This formula is supposed to represent the error and I need to minimize the error. I think I'm supposed to use least squares but I don't know too much about it and I'm wondering what function is best for doing that and what arguments would represent my equation. My teacher also mentioned something about taking derivatives and he formed a matrix using derivatives which confused me even more- am I required to take derivatives?

推荐答案

您必须尝试解决的问题是

The problem that you must be trying to solve is

Min u'u = min \ sum_i u_i ^ 2,u = y-Xbeta,其中u是误差,y是您要解释的因变量的向量,X是自变量的矩阵,且beta是您要估算的向量.

Min u'u = min \sum_i u_i^2, u=y-Xbeta, where u is the error, y is the vector of dependent variables you are trying to explain, X is a matrix of independent variables and beta is the vector you want to estimate.

由于和u_i ^ 2是可微的(并且是凸的),因此您可以计算该表达式的最小值,计算其导数并将其设为零.

Since sum u_i^2 is diferentiable (and convex), you can evaluate the minimal of this expression calculating its derivative and making it equal to zero.

如果执行此操作,则会发现beta = inv(X'X)X'y.可以使用matlab函数回归 http://www.mathworks.com/help/stats/regress.html 或在Matlab中编写此公式.但是,您应该小心如何评估逆(X'X),请参见最有效的矩阵MATLAB中的反演

If you do that, you find that beta=inv(X'X)X'y. This maybe calculated using the matlab function regress http://www.mathworks.com/help/stats/regress.html or writing this formula in Matlab. However, you should be careful how to evaluate the inverse (X'X) see Most efficient matrix inversion in MATLAB

这篇关于最小化MATLAB中公式的误差(最小二乘?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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