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.
I really appreciate the help.
If you are certain the
xydata describe a straight line, you’d do the following.Finding the best fitting straight line equals solving the over-determined linear system
Ax = bin a least-squares sense, whereThis can be done in Matlab like so:
What we’ve done now is find the values for
mandcso that the line described by the equationy = mx+cbest-fits the data you’ve given. This best-fit line is not perfect, so it has errors w.r.t. the y-data:The standard deviation of these errors can be computed like so:
If you want to use the perpendicular distance to the line (Euclidian distance), you’ll have to include a geometric factor:
Using trig identities this can be reworked to
and of course,
If you are not certain that a straight line fits through the data and/or your
xydata essentially describe a point cloud around some common centre, you’d do the following.Find the center of mass (
COM):the distances of all points to the
COM:and the standard deviation thereof: