Calculating area of fitted function to compare with results - Mathematica

874 views Asked by At

H!
I've spent a lot of time reading Mathematica's Document Center and stackoverflow (among other sites), but I haven't found any answer to my question: How in Mathematica I can compare areas (quantitatively) of function (to be precise - results) and its fit. I'd like to get some numerical estimation of my fit. The function of course is in 3D.
Cheers,
John

1

There are 1 answers

0
Vitaliy Kaurov On

If the actual goal is to estimate how good your fit is, then you do not need to calculate any "areas" - Mathematica has built in analysis offered by LinearModelFit[...] and NonlinearModelFit[...]. Let's make up some dataset scattered around a Gaussian surface:

data = MapThread[{#1[[1]], #1[[2]], 
 1.2 Exp[-34 ((#1 - .56).(#1 - .56))] + #2} &, {RandomReal[
 1, {100, 2}], RandomReal[{-.1, .1}, 100]}];

Introduce a Gaussian surface model to fit these data:

model = a Exp[-b ((x - x0)^2 + (y - y0)^2)];

Now, do the nonlinear regression:

    nlm = NonlinearModelFit[data, 
   model, {a, b, {x0, .5}, {y0, .6}}, {x, y}];

Obtain and plot the best fit:

    Show[Plot3D[nlm["BestFit"], {x, 0, 1}, {y, 0, 1}, PlotRange -> All, 
  PlotStyle -> Opacity[.5], MeshStyle -> Opacity[.5], Mesh -> 25], 
 ListPointPlot3D[data, 
  PlotStyle -> Directive[PointSize[Medium], Red]]]

Plot

The function nlm[…] contains a lot of information:

nlm["Properties"]

Properties

Here are few properties relevant to your request:

nlm["ParameterTable"]

Parameter Table

nlm["ANOVATable"]

ANOVA Table

Thanks, Vitaliy