Skip to main content
. 2021 Dec 31;10:e73585. doi: 10.7554/eLife.73585
data = {{t1,y1},{t2,y2},{t3,y3}...,{tm,ym}};
N= N0;

rate =
Function[{a1,a2,k1,k2,t},
Piecewise[{{a1 PDF[HypoexponentialDistribution[Table[ik1,{i,1,N}]],t]
+a2 PDF[HypoexponentialDistribution[Join[Table[ik1,{i,1,N}],{k2}]],t]
                                                     ,t ≥ 0}},0]];
fit = NonlinearModelFit[data,rate[a1,a2,k1,k2,t],
         
{{a1,a10},{a2,a20},{k1,k10},{k2,k20}},t,Method -> "NMinimize"];
fit["ParameterTable"]
Mean[Map[Abs, fit["FitResiduals"]]]