Matlab 多元回归
我有这组变量:
N = 250;
% independent variables[0..10]
x_1 = rand(N,1) * 10;
x_2 = rand(N,1) * 10;
y = ones(N,1); % regresssion variable
y((x_1 + x_2 + rand(N,1) * 2) <= 11) = 2;
我想在 matlab 中进行二元回归,但不知道如何做到这一点,有人可以帮助我吗?线性或多项式回归的结果必须是这两个类之间的直线,存储在 y 中。
I have this set of variables:
N = 250;
% independent variables[0..10]
x_1 = rand(N,1) * 10;
x_2 = rand(N,1) * 10;
y = ones(N,1); % regresssion variable
y((x_1 + x_2 + rand(N,1) * 2) <= 11) = 2;
I want to make two-var regression in matlab, but do not know how to do this, can somebody helps me? The result of linear or polynomial regression must be line between this two classes, stored in y.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个或多个“独立”变量,是一样的。作为示例,有几种解决方法:
请参阅 \ 和 < a href="http://www.mathworks.com/help/techdoc/ref/pinv.html" rel="nofollow">pinv。
Matlab 确实有许多其他方法来求解最小二乘法。您可能想详细说明您的具体情况,以便找到最合适的情况。无论如何,上述文档对您来说是一个很好的起点。
编辑:
关于
最小二乘
的一些值得阅读的一般信息是wiki和mathworksOne or more 'independent' variables, it's the same. Just as an example few ways to solve:
See more of \ and pinv.
Matlab do have many other ways to solve least squares. You may like to elaborate more on your specific case, in order to find the most suitable one. Anyway, above documentation is a good starting point for you.
Edit:
Some general information on
least squares
worthwhile to read are wiki and mathworks