This Python package is an implementation of the Multilevel Generalized Likelihood Uncertainty Estimation (MLGLUE) algorithm, including some utility functions. See the MLGLUE paper here (preprint).
pip install MLGLUE
MLGLUE
uses Ray
for parallelization. Installation using pip install MLGLUE
also installs Ray
as dependency along numpy
and matplotlib
. Using a custom installation, please prepare an environment for Ray
first as described here for version 2.2.0
. The use of other versions of Ray
has not been tested.
A documentation webpage is available here or alternatively under mlglue.readthedocs.io
.
MLGLUE
requires the computational model to be given in the form of a callable with a specific set of arguments and returns:
def my_model(parameters, level, n_levels, obs_x, obs_y, likelihood, run_id)
'''
Parameters
----------
parameters : 1D list-like
the model parameters
level : int
the 0-based level index
n_levels : int
the total number of levels in the hierarchy
obs_x : 1D list-like
virtual observation ordinates (not actually used in
computations)
obs_y : 1D list-like
the observations with which to compute the
likelihood
likelihood : MLGLUE.Likelihoods instance
an instance of any likelihood from MLGLUE.Likelihoods
with which to compute the likelihood
run_id : int or str
an identifier for the model run
Returns
-------
computed_likelihood : float
the computed likelihood
simulated_observation_equivalents : 1D list-like
the simulated equivalents of the observations
'''
# your model code
# using the function parameter_to_observable_map as a placeholder
# for more complex models
simulated_observation_equivalents = parameter_to_observable_map(
parameters
)
# compute likelihood
computed_likelihood = likelihood.likelihood(
obs=obs_y,
sim=simulated_observation_equivalents
)
return computed_likelihood, simulated_observation_equivalents
See the examples directory for a working implementation.