So I have generated a set of random data points as shown below
sample1 = RandomVariate[BinormalDistribution[{0, 0.4}, {1.2, 1.2}, 0], 250];
From the sample, I need to create a list of data points from the data above to fit into the NonlinearModelFit function. And because the NonlinearModelFit function requires the data to be structured in the form of a list of coordinate triples: e.g. {x, y, H[x,y]} where x and y are the pixel locations, and H[x,y] is the histogram value at that x-y coordinate, I need to generate data points.
The function I need to fit is:
A Exp[-((x - μ1)^2 + (y - μ2)^2)/(2 σ^2)]
Here is what I tried (so I first generated a list from the sample data points)
h1 = HistogramList[sample1, {-4, 4, 0.35}, "PDF"]
And then I tried to extract the x-y data points (but it wasn't very successful and I also do not know how to get the H[x,y] or function of x,y pairs as well)
h1xy = Table[{h1[[1, j]], h1[[2, j]]}, {j, 1, Length[h1[[1]]] - 1}]
Would anyone know how to do this that could help me out?
NonlinearModelFit
and you don't want to extract "data" from the construction of aHistogramList
. You want to do what @BobHanlon suggests. $\endgroup$