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

Uncertanty estimation #16

Open
valentinaalb opened this issue Jan 16, 2024 · 4 comments
Open

Uncertanty estimation #16

valentinaalb opened this issue Jan 16, 2024 · 4 comments

Comments

@valentinaalb
Copy link

Hi! Thank you a lot for your code, it has been really helpful!
Do you have any idea on how to extract the uncertainty of the fit?

Best regard!

@aleksandrbazhin
Copy link
Owner

Hi! I haven't used the code for some time. Buy that's what I think on the spot.
It's a least squares method so what we are optimizing for (minimizing) is a sum of all the squared distances between the points and the surface. I can look into the code later If you need help extracting it. You then may take a square root of it and divide it first by the number of points, and then by the mean ellipsoid axis. That would be some reasonable relative uncertainty metric.

@aleksandrbazhin
Copy link
Owner

I maybe wrong here, but I think what you need to look into is computing the residual of that solve

u = np.linalg.solve(D.dot(D.T), D.dot(d2))

@valentinaalb
Copy link
Author

Firstly, thanks for answering! I'm looking exactly at that by replacing np.linalg.solve() with np.linalg.lstsq(), which returns also the residual. Now I'm looking into a meaningful way to normalize it!
Thanks a lot!

@aleksandrbazhin
Copy link
Owner

np.linalg.solve() is slightly different from np.linalg.lstsq(), solve() can be both more precise and efficient. Residual computation is not hard, you just need to take the difference between substituted solution and rhs of the equation. Something like D.dot(u) - d2.
Although I may be vastly wrong in all of this.

You may also look into https://github.com/marksemple/pyEllipsoid_Fit/blob/master/ellipsoid_fit.py - it's another Python port of the same matlab code

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

No branches or pull requests

2 participants