File: calc-nlfit.el.html

This code uses the Levenberg-Marquardt method, as described in
_Numerical Analysis_ by H. R. Schwarz, to fit data to
nonlinear curves. Currently, the only the following curves are supported: The logistic S curve, y=a/(1+exp(b*(t-c)))
  Here, y is usually interpreted as the population of some
  quantity at time t. So we will think of the data as consisting
  of quantities q0, q1, ..., qn and their respective times
  t0, t1, ..., tn.

The logistic bell curve, y=A*exp(B*(t-C))/(1+exp(B*(t-C)))^2
  Note that this is the derivative of the formula for the S curve.
  We get A=-a*b, B=b and C=c. Here, y is interpreted as the rate
  of growth of a population at time t. So we will think of the
  data as consisting of rates p0, p1, ..., pn and their
  respective times t0, t1, ..., tn.

The Hubbert Linearization, y/x=A*(1-x/B)
  Here, y is thought of as the rate of growth of a population
  and x represents the actual population. This is essentially
  the differential equation describing the actual population.

The Levenberg-Marquardt method is an iterative process: it takes an initial guess for the parameters and refines them. To get an initial guess for the parameters, we'll use a method described by Luis de Sousa in "Hubbert's Peak Mathematics". The idea is that given quantities Q and the corresponding rates P, they should satisfy P/Q= mQ+a. We can use the parameter a for an approximation for the parameter a in the S curve, and approximations for b and c are found using least squares on the linearization log((a/y)-1) = log(bb) + cc*t of y=a/(1+bb*exp(cc*t)), which is equivalent to the above s curve formula, and then translating it to b and c. From this, we can also get approximations for the bell curve parameters.

Defined variables (0)

Defined functions (36)

calc-fit-bell-shaped-logistic-curve(ARG)
calc-fit-hubbert-linear-curve(&optional SDV)
calc-fit-s-shaped-logistic-curve(ARG)
math-nlfit-b-logistic-fn(X A C D)
math-nlfit-b-logistic-grad(X A C D)
math-nlfit-b-logistic-params(XDATA YDATA)
math-nlfit-b-logistic-solnexpr(PMS VAR)
math-nlfit-chi-sq(XLIST YLIST PARMS FN &optional SLIST)
math-nlfit-enter-result(N PREFIX VALS)
math-nlfit-find-covar(GRAD XLIST PPARMS)
math-nlfit-find-logistic-parameters(QDATA PDATA TDATA)
math-nlfit-find-q0(PDATA TDATA)
math-nlfit-find-qmax(QDATA PDATA TDATA)
math-nlfit-find-qmaxhalf(PDATA TDATA)
math-nlfit-fit(XLIST YLIST PARMS FN GRAD &optional SLIST)
math-nlfit-fit-curve(FN GRAD SOLNEXPR INITPARMS &optional SDV)
math-nlfit-get-cumul-from-rates(TDATA PDATA Q0)
math-nlfit-get-elt(VEC I)
math-nlfit-get-matx-elt(MAT I J)
math-nlfit-get-rates-from-cumul(TDATA QDATA)
math-nlfit-get-sigmas(GRAD XLIST PPARMS CHISQ)
math-nlfit-givens(C D)
math-nlfit-init-lambda(C)
math-nlfit-jacobian(GRAD XLIST PARMS &optional SLIST)
math-nlfit-least-squares(XDATA YDATA &optional SDATA SIGMAS)
math-nlfit-make-Ctilda(C L)
math-nlfit-make-d(FN XDATA YDATA PARMS &optional SDATA)
math-nlfit-make-dtilda(D N)
math-nlfit-make-ident(L N)
math-nlfit-make-matrix(I J)
math-nlfit-s-logistic-fn(X A B C)
math-nlfit-s-logistic-grad(X A B C)
math-nlfit-s-logistic-params(XDATA YDATA)
math-nlfit-s-logistic-solnexpr(PMS VAR)
math-nlfit-set-elt(VEC I X)
math-nlfit-set-matx-elt(MAT I J X)

Defined faces (0)