Description Usage Arguments Details Value Author(s) See Also
Optimizing a function where first argument is an index.
1 2 |
x |
the monotonic vectorized function to be optimized. The term abs(x(i,...)-target) is minimized. |
target |
Target value for |
... |
additional named or unnamed arguments to be passed to f. |
interval |
a vector containing the end-points of the interval to be searched for target. |
lower |
the lower end point of the interval to be searched. |
upper |
the upper end point of the interval to be searched. |
maxiter |
Maximum number of search iterations. Defaults to 100. |
showiter |
Boolean flag indicating whether the algorithm state should be printed at each iteration. Defaults to FALSE. |
This function can be applied similar to optimize
for cases, where the argument
to be optimized is an index instead of a continuous variable.
A binary search over the index is performed.
The function x
must be monotonic. If it is not strictly monotonic the returned
index ($where
) can be any of the indices with equal values.
The code is based on binsearch of the gtools package. In difference to the original code, it returns always only one best estimate.
A list containing:
call |
How the function was called. |
numiter |
The number of iterations performed |
flag |
One of the strings, "Found", "Between Elements", "Maximum number of iterations reached", "Reached lower boundary", or "Reached upper boundary." |
where |
One or two values indicating where the search terminated. |
value |
Value of the function |
Thomas Wutzler
twMisc
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.