Function: math-nlfit-get-rates-from-cumul
math-nlfit-get-rates-from-cumul is a byte-compiled function defined in
calc-nlfit.el.gz.
Signature
(math-nlfit-get-rates-from-cumul TDATA QDATA)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-nlfit.el.gz
;; The methods described by de Sousa require the cumulative data qdata
;; and the rates pdata. We will assume that we are given either
;; qdata and the corresponding times tdata, or pdata and the corresponding
;; tdata. The following two functions will find pdata or qdata,
;; given the other..
;; First, given two lists; one of values q0, q1, ..., qn and one of
;; corresponding times t0, t1, ..., tn; return a list
;; p0, p1, ..., pn of the rates of change of the qi with respect to t.
;; p0 is the right hand derivative (q1 - q0)/(t1 - t0).
;; pn is the left hand derivative (qn - q(n-1))/(tn - t(n-1)).
;; The other pis are the averages of the two:
;; (1/2)((qi - q(i-1))/(ti - t(i-1)) + (q(i+1) - qi)/(t(i+1) - ti)).
(defun math-nlfit-get-rates-from-cumul (tdata qdata)
(let ((pdata (list
(math-div
(math-sub (nth 1 qdata)
(nth 0 qdata))
(math-sub (nth 1 tdata)
(nth 0 tdata))))))
(while (> (length qdata) 2)
(setq pdata
(cons
(math-mul
'(float 5 -1)
(math-add
(math-div
(math-sub (nth 2 qdata)
(nth 1 qdata))
(math-sub (nth 2 tdata)
(nth 1 tdata)))
(math-div
(math-sub (nth 1 qdata)
(nth 0 qdata))
(math-sub (nth 1 tdata)
(nth 0 tdata)))))
pdata))
(setq qdata (cdr qdata)))
(setq pdata
(cons
(math-div
(math-sub (nth 1 qdata)
(nth 0 qdata))
(math-sub (nth 1 tdata)
(nth 0 tdata)))
pdata))
(reverse pdata)))