View source: R/utils-optimization.R
collect_fn_params | R Documentation |
Useful for converting a regular function into a function amenable to
optimization via stats::optim
, which requires all free parameters be
passed as a single vector par
.
collect_fn_params(fn)
fn |
|
Takes a function of the form f(x, ...), where ... is any number of additional
function parameters (bot not literal ...
!) and parses it to a function of
the form f(par, x) where par
is a vector of values for ... in
the same order as the arguments appear in fn
.
function
A new non-primitive function where the first argument is
par
, which takes a vector of parameters being optimized, and the
second argument is the old first argument to fn
(usually x
since this
is the independent variable to optimize the function over).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.