The interface that a function to be minimised must satisfy.
For Simplex, T should be number[] representing a
point in n-dimensional space
For Brent, T should be number representing a single
real value
For both, the return value must either be a number (the objective
value to be minimised) or Result (a rich result type that
includes the objective value and additional information; see below).
Remarks
Sometimes, it is useful to get additional information out of the
target function and store it alongside the solution - this is what
the Result return type is for. For example, if fitting a
model to data you might end up with a sum-of-squares error used for
target fitting, but the model values themselves are of
interest. For linear regression we might do this by returning a
closure that could be evaluated at any x position:
This can be passed through to Simplex above, and the data
element of Simplex.result() will contain
the predictor function at the best point. (Do not fit linear
regressions with this package - you can do that faster and more
accurately with many other methods.)
Returns
result The value of the target function at location,
either as a simple number or a rich Result type
The interface that a function to be minimised must satisfy.
T
should benumber[]
representing a point in n-dimensional spaceT
should benumber
representing a single real valueFor both, the return value must either be a number (the objective value to be minimised) or Result (a rich result type that includes the objective value and additional information; see below).
Remarks
Sometimes, it is useful to get additional information out of the target function and store it alongside the solution - this is what the Result return type is for. For example, if fitting a model to data you might end up with a sum-of-squares error used for target fitting, but the model values themselves are of interest. For linear regression we might do this by returning a closure that could be evaluated at any
x
position:This can be passed through to Simplex above, and the
data
element ofSimplex.result()
will contain the predictor function at the best point. (Do not fit linear regressions with this package - you can do that faster and more accurately with many other methods.)Returns
result The value of the target function at
location
, either as a simple number or a rich Result type