elfi-dev / elfi

ELFI - Engine for Likelihood-Free Inference
http://elfi.readthedocs.io
BSD 3-Clause "New" or "Revised" License
265 stars 60 forks source link

RandMaxVar update and batch acquisitions #478

Closed uremes closed 6 months ago

uremes commented 6 months ago

Summary:

The randmaxvar acquisitions are sampled from the maxvar acquisition function with an MCMC sampler. Two updates are proposed here:

  1. add option to use prior distribution in sampler initialisation

The acquisition method needs to initialise the MCMC sampler with a point that has maxvar acquisition score (approximate posterior variance) above zero. The current version samples candidate points from a uniform distribution within BOLFI bounds. The updated version includes an option to sample from the prior distribution.

  1. batch acquisitions

The current implementation runs one MCMC chain and returns the batch_size last samples. This works when batch_size=1 but does not provide a representative sample from the maxvar acquisition function otherwise. The version proposed in this update returns the last mcmc sample when batch_size=1 and a random sample from the MCMC chain otherwise.

For illustration, here are batches acquired by running BOLFI on the MA2 example with log-discrepancies using batch_size=10 and the current randmaxvar implementation with sampler=’metropolis’ and n_samples=2000. The batches tend to include 2-4 unique parameter values:

image

These are batches acquired by running the same example using the updated implementation with the same parameters as above and warmup=500. Most batches now include 10 unique parameter values:

image

Please make sure

If your contribution adds, removes or somehow changes the functional behavior of the package, please check that

and the proposed changes pass all unit tests (check step 6 of CONTRIBUTING.rst for details)

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

uremes commented 6 months ago

addressed the feedback that users may not want the prior to be used in sampler initialisation. default option is now to use the uniform distribution, and the user needs to set init_from_prior=True to sample from the prior instead.