metrumresearchgroup / Torsten

library of C++ functions that support applications of Stan in Pharmacometrics
BSD 3-Clause "New" or "Revised" License
52 stars 11 forks source link

[BUG] Incorrect gradient w.r.t. dosing interval "II" #15

Closed yizhang-yiz closed 4 years ago

yizhang-yiz commented 5 years ago

Description

Gradient wrt II is incorrect when ss=1.

Example

In one-cpt test fixture, setup

  time[0] = 0.0;
  time[1] = 5.0;
  resize(2);

  amt[0] = 1200;
  amt[1] = 800;
  rate[0] = 0;
  rate[1] = 0;
  addl[0] = 2;
  addl[1] = 0;
  ii[0] = 1.4;
  ii[1] = 0.7;
  ss[0] = 1;
  ss[1] = 0;

gives wrong gradient compare to finite difference result

g[i] evaluates to 110.33698404186646,
g_fd(i) evaluates to -2807.6201142782033

Expected Output

Consistent gradient within error tolerance.

Current Version:

v0.87.1

yizhang-yiz commented 4 years ago

addressed in https://github.com/metrumresearchgroup/math/pull/31