Robust Estimation of Sphere
이전 댓글 표시
Hi,
I have a point cloud file which represents a sphere. I want to find out the center and the radius of that sphere using some kind of robust estimation (M-estimation, for example). Can someone please help me regarding this?
Thanks in advance.
Zereen
댓글 수: 2
Walter Roberson
2011년 10월 9일
When you say "estimation", do you mean you want to do it without examining all of the data points?
Zereen
2011년 10월 9일
답변 (1개)
the cyclist
2011년 10월 9일
0 개 추천
Zereen, I am not aware of any way to do this "out of the box", and I did not find anything in the File Exchange. Do you have the Statistics Toolbox? If so, I think you could probably do something close to what you want by using the nlinfit() function, along with the 'Robust' option. Read "doc nlinfit" for details.
댓글 수: 12
Zereen
2011년 10월 9일
Zereen
2011년 10월 11일
Sean de Wolski
2011년 10월 11일
you probably have something like
(magic(5))^rand(5);
and actually want
magic(5).^rand(5)
note the .^ means element by element power as opposed to m(atrix)power
Zereen
2011년 10월 11일
Zereen
2011년 10월 11일
the cyclist
2011년 10월 12일
Are you able to upload the txt file somewhere?
Zereen
2011년 10월 12일
the cyclist
2011년 10월 12일
If you breakpoint immediately after your call to nlinfit(), you'll notice that the residual is all zeros at the first iteration, so it has found a solution. The reason it has found a solution is that you have defined the second and third input arguments (y and @hModfun) to be identical. In other words, your fitting function and your empirical data are the same, so the fit is perfect. You have misspecified the inputs.
The basic problem is that your definition of "y" should be purely from your data, but you have included the fitting parameter in there as well. I haven't thought carefully enough about this yet to know how to fix it.
Zereen
2011년 10월 12일
the cyclist
2011년 10월 13일
I think your problem boils down to this. This is going to be a bit pedantic, but that is mostly so I get the logic straight in my own head.
You have a series of (x,y,z), which lie on the surface of a sphere, except there is noise so they are not perfect. Given that series, you want to estimate the center and radius of the sphere. Theoretically (i.e. the fit), the radius is a fixed value, r_fit = r0. Empirically, the radius is r_empirical = sqrt((x-x0).^2+(y-y0).^2+(z-z0).^2).
So, in MATLAB you would LIKE to be able to write that as
>> nlinfit (x, sqrt((x-x0).^2+(y-y0).^2+(z-z0).^2), r0, beta0, options); % Won't work.
But you can't (I think), because that mixes the fitting parameters into both the empirical and the fitted part of nlinfit(). However, I believe that it is OK to instead do that fit by subtracting the "r_empirical" term from both pieces, getting
>> nlinfit (x, 0,r0-sqrt((x-x0).^2+(y-y0).^2+(z-z0).^2), beta0, options); % Almost there.
Getting the syntax right, and using your function handle, I think the following does that:
>> [par_out, residual, J, sigma] = nlinfit (x, zeros(size(X)),@hModfun, beta0, options)
I am not 100% sure that that is theoretically correct, but it does give a solution that is very close to your least-squares answer, so I have some confidence in its correctness.
Zereen
2011년 10월 13일
the cyclist
2011년 10월 13일
One other comment. One thing that made this tricky is that your (x,y,z) data do not contain clear explanatory and response variables, which would normally be the case when fitting data. It really is more of an optimization problem, but we mashed it into a "fitting framework" to make use of the ability to use robust fitting. (Maybe there was a way to do that via something in the Optimization Toolbox, but I don't know.)
An alternative way to have done the fit would be to say that you have a z_fit and a z_empirical, with (x,y) being the explanatory. However, that puts z on a different footing than (x,y), which I didn't think made sense. But it is also a little odd that "r" is the response variable, given (x,y,z). I am not sure how theoretically strong my suggestions were. Let the buyer beware.
카테고리
도움말 센터 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!