tape_gradoffset | R Documentation |
Tape the Gradient Offset of a Quadratic CppAD Tape
tape_gradoffset(pfun)
pfun |
An |
A quadratic function can be written as
f(x;\theta) = \frac{1}{2} x^T W(\theta) x + b(\theta)^Tx + c.
The gradient of f(x; \theta)
with respect to x
is
\Delta f(x; \theta) = \frac{1}{2}(W(\theta) + W(\theta)^T)x + b(\theta).
The Hessian is
H f(x; \theta) = \frac{1}{2}(W(\theta) + W(\theta)^T),
which does not depend on x
,
so the gradient of the function can be rewritten as
\Delta f(x;\theta) = H f(x; \theta) x + b(\theta)^T.
The tape calculates b(\theta)
as
b(\theta) = \Delta f(x;\theta) - H f(x; \theta) x,
which does not depend on x
.
For creating this tape, the values of pfun$xtape
and pfun$dyntape
are used.
An Rcpp_ADFun
object. The independent argument to the function are the dynamic parameters of pfun
.
Other tape builders:
tape_Hessian()
,
tape_Jacobian()
,
tape_logJacdet()
,
tape_smd()
,
tape_swap()
,
tape_uld()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.