Uncertainty of mldivide

4 views (last 30 days)
Kyle
Kyle on 5 May 2011
I am currently working on a research project that involves performing a least squares analysis of circles that are extracted from images in MATLAB. As part of the process of developing the code, I found an example in the documentation that shows how to measure the radius of a roll of tape using bwtraceboundary and then a least squares fit of the (x,y) data points to get a value for the radius. The example uses the backslash operator to perform the least-squares fit of the points.
I have applied a similar procedure to the images that I am analyzing but I also would like to determine the uncertainty of the radius value in the least squares fit. I have searched through the MATLAB documentation to determine the exact steps used in mldivide but it is all very vague.
What is the best way to know how the mldivide function works so that I can calculate the least squares uncertainty for the circle size? I hope this makes sense.
  1 Comment
Oleg Komarov
Oleg Komarov on 5 May 2011
Are you trying to get the standard error of the estimates or the algorithm of mldivide (which TM will not disclose)

Sign in to comment.

Answers (1)

Teja Muppirala
Teja Muppirala on 6 May 2011
Any uncertainty introduced by using MLDIVIDE is many many many orders of magnitude smaller than errors due to having a real-world, imperfect, discrete image.
For example, think about fitting just a simple straight line through a number of points in an image. Say the pixel locations on the image are: x = [10; 20; 30; 40] and y = [50; 70; 90 ; 110]. Well, in real life those points are probably not exactly at 10, 20 30, etc. Your camera only has a finite resolution so the "true" locations might actually be at 9.8, 20.4, 30.2, and you wouldn't know it.
For the given data points, we know the slope of the line should be exactly 2.0, but running a simple simulation introducing a +/- 0.5 pixel uncertainty shows a very nice looking distribution where there is a few percent error each way.
nmax = 100000;
C = zeros(2,nmax);
x = [10; 20; 30; 40];
y = [50; 70; 90; 110;];
for n = 1:nmax
x_uncertain = x+(-0.5+0.5*rand(size(x)));
y_uncertain = y+(-0.5+0.5*rand(size(y)));
C(:,n) = [x_uncertain.^0 x_uncertain.^1]\y_uncertain;
end
hist(C(2,:),100);
This sort of discretization error (and other errors such as the camera not being perfectly in focus, or the image being not perfectly straight or whatever) is the real source of uncertainty in your analysis. The numerical errors from MLDIVIDE depend on a lot of things, but are generally somewhere in the ballpark of something like 10^(-13), which is so small that it is probably not important.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!