Function: math-nlfit-find-qmax
math-nlfit-find-qmax is a byte-compiled function defined in
calc-nlfit.el.gz.
Signature
(math-nlfit-find-qmax QDATA PDATA TDATA)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-nlfit.el.gz
;; Given the qdata, pdata and tdata, find the parameters
;; a, b and c that fit q = a/(1+b*exp(c*t)).
;; a is found using the method described by de Sousa.
;; b and c are found using least squares on the linearization
;; log((a/q)-1) = log(b) + c*t
;; In some cases (where the logistic curve may well be the wrong
;; model), the computed a will be less than or equal to the maximum
;; value of q in qdata; in which case the above linearization won't work.
;; In this case, a will be replaced by a number slightly above
;; the maximum value of q.
(defun math-nlfit-find-qmax (qdata pdata tdata)
(let* ((ratios (math-map-binop 'math-div pdata qdata))
(lsdata (math-nlfit-least-squares ratios tdata))
(qmax (math-max-list (car qdata) (cdr qdata)))
(a (math-neg (math-div (nth 1 lsdata) (nth 0 lsdata)))))
(if (math-lessp a qmax)
(math-add '(float 5 -1) qmax)
a)))