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
Negative standard deviation from Gaussian fit #6014
Comments
Possible fix in #6019. Here is the result using that PR: >>> g_fit
<Gaussian2D(amplitude=984.7681025920282, x_mean=7.198391178949762, y_mean=7.497210019182043,
x_stddev=1.984021909876468, y_stddev=3.184065373194362, theta=16.41338035215769)> |
@pllim Thanks for your effort :)
|
What machine do you have? I used RHEL6 64-bit with Python 3.5.3, Numpy 1.12, and SciPy 0.18. |
I am using Ubuntu 16.04.2 LTS (64-bit), Python 3.6.1, Numpy 1.12.1, SciPy 0.19.0. |
I updated SciPy to 0.19.0 but still gets 984.7681025920282. However, does the difference matter? It is only 0.0001%. Although I do need to tweak "rtol" a bit to make the test pass: result = 984.7681025920282
ans = 984.7694929790363
assert_allclose(result, ans, rtol=1.5e-6) |
To answer your original questions:
<Gaussian2D(amplitude=154.0972375365179,
x_mean=-11.952893612287438, y_mean=-7.442634264703583,
x_stddev=102.29185380715673, y_stddev=32.1563499422225,
theta=1.5707963267948966)> |
I cannot think a case this small difference is a big matter, but I was just a bit curious why the discrepancy happens, though it's small. So I asked just in case you have a clear reason for it :)
I encountered similarly peculiar results when I was using bounding option for fitting different data (It was Moffat2D). I still have no clue for such strange fitted values.. |
FWIW even if theta is out of bounds, the fitted result still looks decent. If only there is some documentation on how to convert crazy looking
Here are the visualized results from my PR (your test data, fitted Gaussian, residuals): |
I have encountered that sig_x = np.abs(g_fit.x_stddev.value)
sig_y = np.abs(g_fit.y_stddev.value)
theta = g_fit.theta.value % (2*np.pi)
if theta > np.pi:
theta = theta - np.pi
if sig_x < sig_y:
theta = theta - np.pi/2 The second |
I could possibly add a new property to |
It has already been pointed out in #1105.
I have the following 17 by 17 array called
test
, and I did a Gaussian 2D fitting and got negativex_stddev
:So here I have two questions:
theta
has so large absolute value, not constrained in (-pi, +pi)?theta
to some arbitrary value, such as (-tt1, +tt2), I get only -tt1 or +tt2, i.e., the boundary values. It seems like the fitter could not find the local minimum well, unless unconstrained. Is there any reason for this?The text was updated successfully, but these errors were encountered: