Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: How to use BestFitParameters?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24301] RE: [mg24274] How to use BestFitParameters?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 7 Jul 2000 00:11:43 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com


> -----Original Message-----
> From: rob [mailto:piovere at pdq.net]
To: mathgroup at smc.vnet.net
> p is a list of data pairs { {x1,y1}, {x2,y2}, ....} and when I fit
> this data to a function Mathematica does a pretty good job of
> doing the fit:
>
> NonlinearRegress[p, a/Sqrt[d^2 + (x1 - w0)^2], {x1}, {a, d, w0},
>   MaxIterations -> 200, RegressionReport -> BestFitParameters]
>
> gives this as an output:
> {BestFitParameters -> {a -> 1.07061, d -> 0.300272, w0 -> 28.8068}}
>
> I know it is pretty a pretty good fit to the data because I can use
> another program like Excel to plot the curve using these parameters
> and display it next to the data.  It sure would be nice to do this in
> Mathematica without going to an outside program.  I've tried things but I
> can't seem to be able to get to the parameters a, d and w0.  I can't
> even list them.  For example,  I'd like to display the number
> d/Sqrt[w0^2-d^2]. So I tried this:
>
> d/Sqrt[w0^2-d^2] /. %
>
> All I get is the formula in symbolic form.
>
> Can someone here provide some relief?
>
> Thanks, Rob
>

Rob,

Follow the form given in In[4] and Out[4] in the NonlinearFit documentation.

rules = BestFitParameters/. NonlinearRegress[p, a/Sqrt[d^2 + (x1 - w0)^2],
{x1}, {a, d, w0},
  MaxIterations -> 200, RegressionReport -> BestFitParameters]

You should get:

{a -> 1.07061, d -> 0.300272, w0 -> 28.8068}

Then:

d/Sqrt[w0^2 - d^2] /. rules
0.0104242

To plot your function:

f[x_] = a/Sqrt[d^2 + (x - w0)^2] /. rules
1.07061/Sqrt[0.090163273984 + (-28.8068 + x)^2]

Plot[f[x], {x, -5, 5}];

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



  • Prev by Date: Re: Division still cost more than multiplication?
  • Next by Date: Re: Findminimum Question
  • Previous by thread: Re: How to use BestFitParameters?
  • Next by thread: Re: How to use BestFitParameters?