Matlab的 - 笛卡尔点的标准偏差 [英] Matlab - Standard Deviation of Cartesian Points

查看:187
本文介绍了Matlab的 - 笛卡尔点的标准偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有笛卡尔点的数组(列1 x值和列2是y值),就像这样:

I have an array of cartesian points (column 1 is x values and column 2 is y values) like so:

308 522
307 523
307 523
307 523
307 523
307 523
306 523

我应如何去获得积分的标准偏差?将它相对于平均值,这将是一条直线。该点是不是直线,所以后来的标准偏差描述如何从该直线的线段是波状或离基地

How would I go about getting a standard deviation of the points? It would be compared to the mean, which would be a straight line. The points are not that straight line, so then the standard deviation describes how wavy or "off-base" from the straight line the line segment is.

我真的AP preciate的帮助。

I really appreciate the help.

推荐答案

如果您确定 XY 数据描述一条直线,你会做以下。

If you are certain the xy data describe a straight line, you'd do the following.

寻找最佳拟合直线等于求解超定线性系统 Ax = b的在最小二乘意义上,其中

Finding the best fitting straight line equals solving the over-determined linear system Ax = b in a least-squares sense, where

xy = [
308 522
307 523
307 523
307 523
307 523
307 523
306 523];

x_vals = xy(:,1);
y_vals = xy(:,2);

A = [x_vals ones(size(x_vals))];
b = y_vals;

这可以在Matlab来完成,像这样:

This can be done in Matlab like so:

sol = A\b;

m = sol(1);
c = sol(2);

我们现在所做的是,这样的描述行找到 M C 的值方程表达式y = mx + C 最适合你给出的数据。这种最佳拟合线是不完美的,所以它有错误w.r.t.在y数据:

What we've done now is find the values for m and c so that the line described by the equation y = mx+c best-fits the data you've given. This best-fit line is not perfect, so it has errors w.r.t. the y-data:

errs = (m*x_vals + c) - y_vals;

这些错误的标准差,可以计算像这样:

The standard deviation of these errors can be computed like so:

>> std(errs)
ans = 
    0.2440

如果你想使用的垂直距离的线(欧氏距离),你必须有一个几何系数:

If you want to use the perpendicular distance to the line (Euclidian distance), you'll have to include a geometric factor:

errs = (m*x_vals + c) - y;
errs_perpendicular = errs * cos(atan(m));

使用三角恒等式这可以修改,以

Using trig identities this can be reworked to

errs_perpendicular = errs * 1/sqrt(1+m*m);

和当然的,

>> std(errs_perpendicular)
ans = 
    0.2182

如果您不能确定一条直线拟合,通过和/或你的 XY 数据基本描述周围的一些公共中心的点云数据,你会做以下。

If you are not certain that a straight line fits through the data and/or your xy data essentially describe a point cloud around some common centre, you'd do the following.

查找质量中心( COM

COM = mean(xy);

所有点的距离的 COM

dists = sqrt(sum(bsxfun(@minus, COM, xy).^2,2));

和标准偏差或其

>> std(dists)
ans =  
    0.5059

这篇关于Matlab的 - 笛卡尔点的标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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