Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why you may get unpredictable results. #11

Open
aleksandrbazhin opened this issue Jul 22, 2020 · 0 comments
Open

Why you may get unpredictable results. #11

aleksandrbazhin opened this issue Jul 22, 2020 · 0 comments

Comments

@aleksandrbazhin
Copy link
Owner

aleksandrbazhin commented Jul 22, 2020

If you are trying to fit an ellipsoid to arbitrary set of data points, you may and most likely will get unpredictable results. Least square method is supposed to be used on data, which is close to ellipse, like magnetometer calibration data. There is a lot of possibilities to use it with any data, but you may have first to refine it. Some times you may want a minimal containing ellipsoid, sometimes you may use a convex hull first and then fit an ellipsoid.

I'll try to explain on fitting a circle on a plain.

Let say you want to fit a circle to 9 points like that (consider center points to be very close to zero).
Points

If you expect to get a "reasonable" result like
Circle 1
The sum of square distances from point to circle is 1^2*5 = 5
To get such a circle, you first have to throw away center points by constructing convex hull, or just directly find minimal enclosing ellipsoid, instead of using this repository.

Maybe you think outer point are outliers and expect a result like
Circle 2
The sum of squares is 1^2*4 = 4
Then you need to preprocess data by throwing away outliers by any empirical criteria for example

Next you will think that using ellipsoid and LSM, like here, will give you something like that
Circle 3
To find optimal radius we need to minimize 4*(1-x)^2 + 5*x^2. The resulting radius is 4/9 and the sum is 20/9 which is 2.22... To get something like this you would need to fix the center of the ellipse, but the purpose of the code in this repository is to find the offset of a fitted ellipse as well as it's parameters. (I think, it can be added as an option, though)

Well you won't get this. Which you'll get is a circle close to circle through 3 points
Circle 4
The sum here is 1^2*2 = 2, which is already the least of all other variants.

But if we move it a little bit to the two points, which are not on the circle, we will get even smaller sum of squares. And also with symmetrical data like in this explanation, the circle is undefined, since it can be placed in any of 4 directions. So a tiny perturbation in any point's position will cause the fitted ellipse to move by a large distance. And in 3D space it is much harder to predict the results.

I hope this explanation helps anyone looking for a silver bullet for their search for optimal ellipsoids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant