The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: NonlinearModelFit Problem
Replies: 3   Last Post: Jan 18, 2013 12:50 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 9
Registered: 3/20/11
NonlinearModelFit Problem
Posted: Jan 16, 2013 1:38 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I hope I'm doing something obviously stupid, but I can't figure it
out. I'm trying to fit a list of points [x, z, y] (in a cartesian
coordinate system) that very closely approximate a shallow sphereical
cap. The cap was generated by cutting an approximate sphere with a
plane approximately parallel to the x-z plane so that the cap is
apprximately symmetrical around the y-axis. Thus the cap can be
expressed conveniently as y[x,z], but only less accurately as y[r],
where r = Sqrt[x^2 + z^2], because the original sphere's center was
not exactly on the y-axis. I have very good guesses for the center
location and the radius of curvature; I want more accurate values for
these parameters from the fit.

The following expression incorporating all of the degrees of freedom
will not converge but wanders off toward very large values of all

nlm = NonlinearModelFit[distortedNodeLocations,
-Sqrt[fitRadiusOfCurvature^2 - (x - fitxOffset)^2 -
(z - fitzOffset)^2] + fityOffset + radiusOfCurvature +
originalOffset, {{fitRadiusOfCurvature,
radiusOfCurvature}, {fitxOffset, 0.}, {fityOffset, 0.},
{fitzOffset, 0.}}, {x, z}, AccuracyGoal -> 8,
PrecisionGoal -> 12, MaxIterations -> 1000]

(originalOffset is just a constant that forces the spherical cap to
cut the y-axis where I wnat.) In trying to diagnose the problem, I
eventually converted the data l1st to the form, [r, y] (r as defined
above) and successfully fitted it with a simple two-parameter model
(neglecting fitxOffset and fitzOffset):

nlm = NonlinearModelFit[radialFitData,
-Sqrt[fitRadiusOfCurvature^2 - r^2] + fityOffset +
radiusOfCurvature + originalOffset,
{{fitRadiusOfCurvature, radiusOfCurvature},
{fityOffset, 0.}}, r, AccuracyGoal -> 15]

The above model converges very well, yields reasonable values for
fitRadiusOfCurvature and fityOffset, and gives a very low RMS
residual. BUT when I try to fit what should be an essentially
identical model to the original data list, the convergence fails as
describe above for the full model:

nlm = NonlinearModelFit[distortedNodeLocations,
-Sqrt[fitRadiusOfCurvature^2 - x^2 - z^2] + fityOffset +
radiusOfCurvature + originalOffset,
{{fitRadiusOfCurvature, radiusOfCurvature},
{fityOffset, 0.}}, {x, z}, AccuracyGoal -> 8,
PrecisionGoal -> 12, MaxIterations -> 1000]

Even more puzzling, if I constrain the two parameters closely to the
guesses in the above fit, the constrained RMS residual is very much
larger that that obtained when fitting the [r, y] data.

I haven't tried using FindFit yet, as the help files imply that it
uses the same fitting engine. Any suggestions would be greatly
appreciated. -- jclarkw

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.