[Date Index]
[Thread Index]
[Author Index]
RE: Applying Math 6
*To*: mathgroup at smc.vnet.net
*Subject*: [mg82341] RE: [mg82274] Applying Math 6
*From*: "David Annetts" <davidannetts at aapt.net.au>
*Date*: Thu, 18 Oct 2007 04:47:58 -0400 (EDT)
*References*: <200710170747.DAA13615@smc.vnet.net>
Hi Johan,
> I need to fit x-y data to the equation below and also need to
> determine the derivative.
> Please help.
>
> y=exp[-(a*ln(x))/bc]^d + exp[-(a*ln(x)/be]^f
>
> This equation is used in adsorption studies and is normally
> referred to as the Dubinin-Izotova equation.
The first thing would be to read at least guide/MathematicalFunctions in the
online help (assuming 6.0.x).
Your model is
mdl = Exp[-(a*Log[x])/bc]^d + Exp[-(a*Log[x])/be]^f
and we can get its derivative wrt x using
D[mdl, x] // Simplify
Check that this is OK by integrating
Integrate[%, x]//Simplify
As to your problem ....
We can generate some noisy test data (then plot them) using
data = Table[{x, RandomReal[{.01, .01}] x + mdl} /. {a -> 1, be ->
.5, bc -> 2, d -> 2, f -> 3}, {x, 1, 10, .1}];
ListPlot[data]
I don't know whether these parameter values are realistic; I guess that's
your field.
Standard nonlinear least-squares fitting is accomplished using
fit = FindFit[data, mdl, {a, bc, be, d, f}, x]
and we can compare the original data with the modelled data using
Show[{
ListPlot[data],
Plot[mdl /. fit, {x, 1, 10}]
},
PlotRange -> All]
There is a nonlinear least square fitting package that we can load
Needs["NonlinearRegression`"]
usage is similar to FindFit, and
nlfit = NonlinearRegress[data, mdl, {a, bc, be, d, f}, x]
gives exactly the same answers as FitFit but with more diagnostic
information.
If we know starting parameters, then
nlf = NonlinearRegress[data, mdl, {{a, 1}, {bc, 2}, {be, .5}, {d,
2}, {f, 3}}, x,
RegressionReport -> {BestFit, PredictedResponse}]
and this also gives the parameters found by FindFit (compare BestFit /. nlf
with mdl /. fit).
We can compare our models with our data using
Show[{
ListPlot[data],
Plot[mdl /. fit, {x, 1, 10}],
ListPlot[Transpose[{Range[1, 10, .1], PredictedResponse /. nlf}],
Joined -> True, PlotStyle -> Red]
},
PlotRange -> All]
Straightforward, and powerful. But only after learing a bit of syntax.
Regards,
Dave.
Prev by Date:
**Re: Mathematica 6.01 and openSUSE 10.3**
Next by Date:
**Re: Integrate question**
Previous by thread:
**Applying Math 6**
Next by thread:
**Re: Applying Math 6**
| |