Skip to content

Functions to manipulate the control vector and compute cost/log-posterior #301

Description

@benRenard

For many applications, one needs to pass a function that evaluates the cost (or the log-posterior) from the control vector. For instance:

  1. MCMC sampling: samples=MCMC(logpost_function, starting_point, MCMC_args, **logpost_function_args)
  2. Hessian computation: hess=Hessian(cost_function, evaluation_point, Hessian_args, **cost_function_args)
  3. Using a Python optimizer: optim(cost_function, starting_point, optim_args, **cost_function_args)
  4. etc.

To facilitate this, the following functions would be useful (interfaces are approximate, just to convey the idea):

  1. retrieve the control vector from model and optim/cost options: control=smash.get_control(model,mapping,optimize_options,cost_options)
  2. "unfold" a control vector into model parameters: model.set_control(control,mapping,optimize_options,cost_options)
  3. compute the cost using parameters currently in model: cost=smash.get_cost(model,mapping,optimize_options,cost_options)
  4. compute the jacobian vector dcost/dcontrol using parameters currently in model: jac=smash.get_jacobian(model,mapping,optimize_options,cost_options)
  5. make a forward run from the control vector, and (optionally) retrieve cost and jacobian: model,cost,jacobian=smash.forward_run_from_control(control,model,mapping,optimize_options,cost_options)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions