0
$\begingroup$

If I have the following data:

data= {{-2., 0.147789}, {-1.52288, 0.237749}, {-1., 0.476084}, {-0.522879, 
  0.641128}, {-4.82164*10^-17, 1.04976}, {0.477121, 1.43399}, {1., 
  1.77276}, {1.47712, 2.23469}, {2., 2.46328}, {2.47712, 
  2.85828}, {3., 2.96392}, {3.47712, 2.91354}, {4., 3.02119}}

which plotted as:

ListPlot[data, PlotRange -> All, AspectRatio -> 1 , Frame -> True, Axes -> False, AspectRatio -> 1, FrameStyle -> Directive[Black, 13], FrameLabel -> {Style["Log t(s)", 16], Style["\!\(\*SubscriptBox[\(\[CapitalDelta]H\), \ \(a\)]\)(\!\(\*SuperscriptBox[\(Jg\), \(-1\)]\))", 16]}]

gives:

enter image description here

Questions:

  1. How can I fit that data to the following equation using Mathematica:

enter image description here

Where ΔHa (ta) is what I am plotting in the y-axis, t is what I am plotting in the x axis (notice that time is in Log10 scale in the x-axis of the plot) and τ0 and β are the best fitting parameters of the equation. ΔHa(∞) is simply the average of the last three data calculated as DHinfinity = Mean[{3.02119, 2.91354, 2.96392}]

  1. How can i get the fitting parameters τ0 and β?
$\endgroup$

1 Answer 1

3
$\begingroup$
Clear["Global`*"]

data = {{-2., 0.147789}, {-1.52288, 0.237749}, {-1., 
    0.476084}, {-0.522879, 0.641128}, {-4.82164*10^-17, 
    1.04976}, {0.477121, 1.43399}, {1., 1.77276}, {1.47712, 
    2.23469}, {2., 2.46328}, {2.47712, 2.85828}, {3., 
    2.96392}, {3.47712, 2.91354}, {4., 3.02119}};

{logtmin, logtmax} = MinMax[data[[All, 1]]]

(* {-2., 4.} *)

DHinfinity = Mean[data[[All, 2]][[-3 ;;]]]

(* 2.96622 *)

EDIT: Corrected model to use Log10[t] vice Log[t]. This does not change the fit, merely the parameter values. Also added constraint that 0 < b < 1 (unnecessary in this particular case)

(nlm = NonlinearModelFit[
    data, {DHinfinity (1 - Exp[-(10^logt/tau)^b]), 0 < b < 1}, {tau, b}, 
    logt]) // Normal

(* 2.96622 (1 - E^(-0.40494 (10^logt)^0.356033)) *)

nlm["BestFitParameters"]

(* {tau -> 12.6687, b -> 0.356033} *)

Plot[nlm[logt], {logt, logtmin, logtmax},
 PlotRange -> All,
 AspectRatio -> 1,
 Frame -> True,
 Axes -> False,
 AspectRatio -> 1,
 FrameStyle -> Directive[Black, 13],
 FrameLabel -> {Style[StringForm["`` t (s)", Subscript[Log, 10]], 16], 
   Style["\!\(\*SubscriptBox[\(ΔH\), \ \
\(a\)]\)(\!\(\*SuperscriptBox[\(Jg\), \(-1\)]\))", 16]},
 Epilog -> {Red, AbsolutePointSize[4], Point[data]}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Bob Hanlon, thank you very much. The code is fantastic and works great! I really appreciate it ! $\endgroup$
    – John
    Dec 20, 2020 at 22:14
  • 1
    $\begingroup$ Yes, added (unnecessary) constraint and corrected to use Log10 vice Log $\endgroup$
    – Bob Hanlon
    Dec 21, 2020 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.