[Date Index]
[Thread Index]
[Author Index]
Re: Using Fit to interpolate data
*To*: mathgroup at smc.vnet.net
*Subject*: [mg127449] Re: Using Fit to interpolate data
*From*: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
*Date*: Thu, 26 Jul 2012 03:31:44 -0400 (EDT)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*Delivered-to*: mathgroup-newout@smc.vnet.net
*Delivered-to*: mathgroup-newsend@smc.vnet.net
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]
Hi, Kris,
It is certainly possible to fit your list. The question is only in the choice of functions. For example, try this:
(* This are your list and its plot *)
fiber = Sort[{{16, 0}, {10.7, 0.11}, {10.4, 0.19}, {9.77,
0.41}, {8.29, 3.05}, {7.14, 19.86}}];
fPlot = ListPlot[fiber, PlotMarkers -> {Automatic, Small},
AxesOrigin -> {7, 0}, PlotStyle -> Red];
(* This is its fit with the first function that came into mind *)
fFit = Fit[fiber, {1, x^0.3/(x - 7)}, x]
plFit = Plot[fFit, {x, 7.1, 16}, PlotRange -> All];
(* This is the mean square difference between the fit function and \
the list, the measure of proximity *)
msq = Sqrt@
Mean@Table[((fFit /. x -> fiber[[i, 1]]) - fiber[[i, 2]])^2, {i, 1,
Length[fiber]}];
(* Here you can see, how good the fit works, and inset gives the above \
mean square difference *)
Show[{fPlot, plFit}, Epilog -> Inset[msq, Scaled[{0.8, 0.8}]]]
You can now play with the power of x and (x-7) and look at the msq value to=
be the smallest possible.
However, my choice of the function was only determined by the form of the ListPlot, not by the biological/physical sense of your problem. In this form you only may use it for the purposes of the interpolation within the interval {7.14, 16}, but not for extrapolation. If extrapolation is your aim, it would be much better, if you have some other reasons (say, coming from a theory, if you have any) for the choice of the fitting functions.
Further, if the precision of fitting is not enough, you should look for other functions then I used, or for their combinations. The use of FindFit instead of Fit may then be helpful.
Have fun, Alexei
Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG
Office phone : +352-2454-2566
Office fax: +352-2454-3566
mobile phone: +49 151 52 40 66 44
e-mail: alexei.boulbitch at iee.lu
Prev by Date:
**Re: Sending an interrupt to the frontend?**
Next by Date:
**Re: Countur/Density plot on sphere**
Previous by thread:
**Re: Using Fit to interpolate data**
Next by thread:
**Re: Using Fit to interpolate data**
| |