Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11066
| From | Barrie Stokes <Barrie.Stokes@newcastle.edu.au> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Using Fit to interpolate data |
| Date | 2012-07-25 06:33 +0000 |
| Message-ID | <juo3v5$16d$1@smc.vnet.net> (permalink) |
| References | <20120724081518.A77C26839@smc.vnet.net> |
| Organization | Time-Warner Telecom |
Hi Kris
The code (mostly adapted from the help for FindFit):
model = a Exp[-k x + m ]
fit = FindFit[fiberDataDensitiesFeierabend, model, {a, k, m}, x]
modelf = Function[{x}, Evaluate[model /. fit]]
(*************)
Plot[modelf[x], {x,
Min[Subscript[fiberDataDensitiesFeierabend, [[ All, 1 ]]]],
Max[Subscript[fiberDataDensitiesFeierabend, [[ All, 1 ]]]]},
PlotRange -> All,
Epilog -> Map[Point, fiberDataDensitiesFeierabend], Frame -> True]
Plot[modelf[x], {x, 10, 16}, PlotRange -> All,
Epilog -> Map[Point, fiberDataDensitiesFeierabend], Frame -> True]
(*************)
{tl, yl} = Transpose[fiberDataDensitiesFeierabend];
residuals = yl - Map[modelf, tl];
ListPlot[residuals, Filling -> Axis, DataRange -> {Min[tl], Max[tl]},
PlotRange -> All, Frame -> True]
suggests that there is no simple smooth curve that goes through all your data points, and if you interpolate, you will get some negative values of the interpolating function.
Cheers
Barrie
>>> On 24/07/2012 at 6:15 pm, in message <20120724081518.A77C26839@smc.vnet.net>,
Kris Carlson <carlsonkw@gmail.com> wrote:
> Hi,
>
> Can someone enlighten me about how to fit a curve to data? These data are
> of the density of axons of given diameters in the spinal cord. The density
> of smaller fibers is dramatically larger than that of larger fibers. There
> cannot be density < 0 of any diameter, so heuristically to prevent a fit
> yielding an equation that dips below 0 I added an end point with fiber
> diameter = 16 that is 0. Then using Fit I try to increase the exponent of x
> until the curve doesn't yield negative values. The fit looks good in large
> scale but when I plot the region of greatest interest, 8 < x < 14, it no
> longer looks so good. Maybe I am simply ignorant about fitting a curve to
> somewhat irregular data? Or can it be done?
>
> Thank you.
>
> Kris
>
> fiberDataDensitiesFeierabend = {{16, 0}, {10.7, 0.11}, {10.4,
> 0.19}, {9.77, 0.41}, {8.29, 3.05}, {7.14, 19.86}};
>
> fbddPlot =
> ListPlot[fiberDataDensitiesFeierabend,
> PlotMarkers -> {Automatic, Medium}]
>
> fbddFit = Fit[fiberDataDensitiesFeierabend, {1, x, x^-13}, x]
>
> Show[Plot[fbddFit, {x, 4, 20},
> PlotRange -> {{4.5, 20}, {-0.5, 25}}], fbddPlot]
>
> Show[Plot[fbddFit, {x, 4, 28},
> PlotRange -> {{8, 16}, {-0.5, 1}}], fbddPlot]
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Using Fit to interpolate data Barrie Stokes <Barrie.Stokes@newcastle.edu.au> - 2012-07-25 06:33 +0000
csiph-web