GithubHelp home page GithubHelp logo

dstkeehan / microlensing-model-inference Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 291 KB

Code accompanying the paper "Microlensing model inference with normalising flows and reversible jump MCMC"

Home Page: https://dx.doi.org/10.1016/j.ascom.2022.100657

License: MIT License

Python 100.00%
bayesian-inference gravitational-lensing reversible-jump-mcmc

microlensing-model-inference's Introduction

microlensing-model-inference

The estimation of parameters for gravitational microlensing events typically proceeds by fitting proposed lens models to observed data. A problem arises in this approach when alternate parameter values or models produce similar representations, since some comparison must be made between them. This is a challenging problem which has been frequently tackled via Bayesian model selection. Previously this was impractical since the gravitational microlensing joint model posterior is multi-modal and the computational expense required to sample an accurate discretisation prohibitive. Recently Zhang et al. (2021) showed how a neural network can be used to quickly approximate the model dependent posterior distribution of gravitational microlensing data. We show how, in combination with technqiues from Bayesian statistics, this can be used to estimate marginal model probabilities from gravitational microlensing data by speeding up the previously prohibitively slow sampling burn-in period.

This library implements an adaptive reversible-jump algorithm that efficiently refines a suite of surrogate posteriors to the true joint model posterior.

This is a code repository for the paper Microlensing model inference with normalising flows and reversible jump MCMC.

Exemplar Posterior

To estimate the marginal model probabilities, the adaptive reversible-jump algorithm constructs a discrete analogue of the true posterior that is joint over all candidate models. For example:

(a) ARJMH estimated joint-model posterior of a clear binary lensing event compared to the surrogate posterior of each candidate lens model. Off-diagonals show the 1, 2 and 3โˆ’ฯƒ contours of each surrogate posterior in orange and the joint posterior in blue. The lower the density of the contour the lower its opacity. Note that there are no contours shown in the single lensing region of the joint model posterior as it essentially contains no density (the lightcurve is beleived to be generated by binary lensing). True binary parameter values are shown in grey, and single and binary map samples respectively shown in green and purple. The diagonal shows the marginal distributions of each parameter. The parameter fs is not shown for clarity. (b) True light curve and resulting map estimates. (c) The IAC of the model index parameter.

The data from this figure was constructed with example_inference.py.

Dependencies

This library uses MulensModel to model gravitational microlensing systems.

Usage

To construct synthetic gravitational microlensing data and initialise a single lens model:

import distributions
import light_curve_simulation
import sampling

# Generate a discrete synthetic single lens event (with added noise).
parameters = [0.9, 15.0, 1.1, 32.0]
theta = sampling.State(truth=parameters)
n_observations = 720
signal_to_noise_ratio = 23

data = light_curve_simulation.synthetic_single_lens(theta, n_observations, signal_to_noise_ratio)

# Create a list of single lens parameter prior distributions.
fs_pi = distributions.LogUniform(0.1, 1)
t0_pi = distributions.Uniform(0, 72)
u0_pi = distributions.Uniform(0, 2)
tE_pi = distributions.LogUniform(1, 100)

single_priors = [fs_pi, t0_pi, u0_pi, tE_pi]

# Initialise the single lens model Gaussian proposal distribution (a guess* at the true covariance of this model's posterior).
single_covariance = [[0.1, 0.0, 0.0, 0.0],
                     [0.0, 1.0, 0.0, 0.0],
                     [0.0, 0.0, 0.1, 0.0],
                     [0.0, 0.0, 0.0, 1.0]]

# Initialise the single lens model centre (a guess* at the true parameters).
single_centre = sampling.State(truth=[0.9, 15.0, 1.1, 32.0])

# Initialise the single lens model.
model_index = 0
dims = 4
single_Model = sampling.Model(model_index, dims, single_centre, single_priors, single_covariance, \
                                  data, light_curve_simulation.single_log_likelihood)

To sample from a joint single/binary lens model posterior:

# Create pool of models.
Models = [single_Model, binary_Model]

# Sample from the joint posterior.
joint_model_chain, maximum_aposteriori_parameter_estimates, _, _ = \
                               sampling.ARJMH(Models, iterations, warm_up_iterations)

*In the paper Microlensing model inference with normalising flows and reversible jump MCMC the centres and covariances are derived from surrogate posteriors generated from neural networks.

Authors and Acknowledgements

Reversible-jump algorithm and supporting code created by Dominic Keehan.

Neural networks and surrogate posteriors created by Jack Yarndley.

Bachelor of Engineering Science Honours project at the University of Auckland, supervised by Nicholas Rattenbury.

microlensing-model-inference's People

Contributors

dstkeehan avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.