Function: math-nlfit-get-cumul-from-rates
math-nlfit-get-cumul-from-rates is a byte-compiled function defined in
calc-nlfit.el.gz.
Signature
(math-nlfit-get-cumul-from-rates TDATA PDATA Q0)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-nlfit.el.gz
;; Next, given two lists -- one of rates p0, p1, ..., pn and one of
;; corresponding times t0, t1, ..., tn -- and an initial values q0,
;; return a list q0, q1, ..., qn of the cumulative values.
;; q0 is the initial value given.
;; For i>0, qi is computed using the trapezoid rule:
;; qi = q(i-1) + (1/2)(pi + p(i-1))(ti - t(i-1))
(defun math-nlfit-get-cumul-from-rates (tdata pdata q0)
(let* ((qdata (list q0)))
(while (cdr pdata)
(setq qdata
(cons
(math-add (car qdata)
(math-mul
(math-mul
'(float 5 -1)
(math-add (nth 1 pdata) (nth 0 pdata)))
(math-sub (nth 1 tdata)
(nth 0 tdata))))
qdata))
(setq pdata (cdr pdata))
(setq tdata (cdr tdata)))
(reverse qdata)))