I have a dataset which is a moderately large (1200x1200) array of values. A part of that array has the data that is gaussian along the 2 diagonals. Find the general area of the peak is trivial with a binarize. But then I'm trying to find the actual peak center that obeys a normal on both axes.
Sample data here https://pastebin.com/MaEkwBwf
I'm trying to get a fit for that but I don't have a good grasp on how to pass the aray to NonLinearModelFit
The function I'm trying to fit is
a = 150000;
x0 = 100;
y0 = 100;
sx = 5;
sy = 10;
th = Pi/4;
Plot3D[
a*Exp[-(
(Cos[th]*x - Sin[th]*y - (Cos[th]*x0 - Sin[th]*y0))^2/(2*
sx^2) + (Sin[th]*x +
Cos[th]*y - (Sin[th]*x0 + Cos[th]*y0))^2/(2*sy^2)
)]
, {x, 0, 200}, {y, 0, 200}, PlotRange -> All]
In this case the free parameters would be a, x0, y0, sx, sy, th
NonlinearModelFit[
data,
a*Exp[-(
(Cos[th]*x - Sin[th]*y - (Cos[th]*x0 - Sin[th]*y0))^2/(2*
sx^2) + (Sin[th]*x +
Cos[th]*y - (Sin[th]*x0 + Cos[th]*y0))^2/(2*sy^2)
)],
{a, x0, y0, sx, sy, th},
{x, y}]
NonlinearModelFit::Number of coordinates (200) is not equal to the number of variables (2).
NonlinearModelFit
and you should sue whoever taught you to consider that. $\endgroup$