queens.models.likelihood_models package#

Likelihood models.

Modules for probabilistic likelihood models.

Submodules#

queens.models.likelihood_models.bayesian_mf_gaussian_likelihood module#

Multi-fidelity Gaussian likelihood model.

class BMFGaussianModel(forward_model, mf_interface, mf_subiterator, experimental_data_reader, mf_approx, noise_value=None, num_refinement_samples=None, likelihood_evals_for_refinement=None)[source]#

Bases: LikelihoodModel

Multi fidelity likelihood function.

Multi-fidelity likelihood of the Bayesian multi-fidelity inverse analysis scheme [1, 2].

coords_mat#

Row-wise coordinates at which the observations were recorded

Type:

np.array

time_vec#

Vector of observation times

Type:

np.array

output_label#

Name of the experimental outputs (column label in csv-file)

Type:

str

coord_labels#

List with coordinate labels for (column labels in csv-file)

Type:

lst

mf_interface#

QUEENS multi-fidelity interface

Type:

obj

mf_subiterator#

Subiterator to select the training data of the probabilistic regression model

Type:

obj

normal_distribution#

Mean field normal distribution object

Type:

obj

noise_var#

Noise variance of the observations

Type:

np.array

likelihood_counter#

Internal counter for the likelihood evaluation

Type:

int

num_refinement_samples#

Number of additional samples to train the multi-fidelity dependency in refinement step

Type:

int

likelihood_evals_for_refinement#

List with necessary number of likelihood evaluations before the refinement step is conducted

Type:

lst

Returns:
  • Instance of BMFGaussianModel. This is a multi-fidelity version of the

  • Gaussian noise likelihood model.

References

[1] Nitzler, J.; Biehler, J.; Fehn, N.; Koutsourelakis, P.-S. and Wall, W.A. (2020),

“A Generalized Probabilistic Learning Approach for Multi-Fidelity Uncertainty Propagation in Complex Physical Simulations”, arXiv:2001.02892

[2] Nitzler J.; Wall, W. A. and Koutsourelakis P.-S. (2021),

“An efficient Bayesian multi-fidelity framework for the solution of high-dimensional inverse problems in computationally demanding simulations”, unpublished internal report

static build_approximation(bmfia_subiterator, bmfia_interface, approx, coord_labels, time_vec, coords_mat)[source]#

Construct the probabilistic surrogate / mapping.

Surrogate is calculated based on the provided training-data and optimize the hyper-parameters by maximizing the data’s evidence or its lower bound (ELBO).

Parameters:
  • bmfia_subiterator (bmfia_subiterator) – BMFIA subiterator object.

  • bmfia_interface (bmfia_interface) – BMFIA interface object.

  • approx (Model) – Approximation for probabilistic mapping.

  • coord_labels (list) – List of coordinate labels.

  • time_vec (np.array) – Time vector of the experimental data.

  • coords_mat (np.array) – (Spatial) Coordinates of the experimental data.

evaluate(samples)[source]#

Evaluate multi-fidelity likelihood.

Evaluation with current set of variables which are an attribute of the underlying low-fidelity simulation model.

Parameters:

samples (np.ndarray) – Evaluated samples

Returns:

dict – Vector of log-likelihood values per model input.

evaluate_from_output(samples, forward_model_output)[source]#

Evaluate multi-fidelity likelihood from forward model output.

Parameters:
  • samples (np.ndarray) – Samples to evaluate

  • forward_model_output (np.ndarray) – Forward model output

Returns:

mf_log_likelihood (np.array) – Vector of log-likelihood values per model input.

evaluate_mf_likelihood(x_batch, y_lf_mat)[source]#

Evaluate the Bayesian multi-fidelity likelihood as described in [1].

Parameters:
  • x_batch (np.array) – Input batch matrix; rows correspond to one input vector; different dimensions along columns

  • y_lf_mat (np.array) – Response matrix of the low-fidelity model; Row-wise corresponding to rows in x_batch input batch matrix. Different coordinate locations along the columns

Returns:

log_lik_mf_output (tuple) – Tuple with vector of log-likelihood values per model input and potentially the gradient of the model w.r.t. its inputs

References

[1] Nitzler, J., Biehler, J., Fehn, N., Koutsourelakis, P.-S. and Wall, W.A. (2020),

“A Generalized Probabilistic Learning Approach for Multi-Fidelity Uncertainty Propagation in Complex Physical Simulations”, arXiv:2001.02892

grad(samples, upstream_gradient)[source]#

Evaluate gradient of model w.r.t. current set of input samples.

Consider current model f(x) with input samples x, and upstream function g(f). The provided upstream gradient is \(\frac{\partial g}{\partial f}\) and the method returns \(\frac{\partial g}{\partial f} \frac{df}{dx}\).

Parameters:
  • samples (np.array) – Input samples

  • upstream_gradient (np.array) – Upstream gradient function evaluated at input samples \(\frac{\partial g}{\partial f}\)

Returns:

gradient (np.array) – Gradient w.r.t. current set of input samples \(\frac{\partial g}{\partial f} \frac{df}{dx}\)

grad_log_pdf_d_ylf(m_f_vec, grad_m_f_dy, grad_var_y_dy)[source]#

Calculate the gradient of the logpdf w.r.t. to the LF model output.

The gradient is calculated from the individual partial derivatives and then composed in this method.

Parameters:
  • m_f_vec (np.array) – mean vector of the probabilistic surrogate evaluated at sample points

  • grad_m_f_dy (np.array) – gradient of the mean function/vector of the probabilistic regression model w.r.t. the regression model’s input

  • grad_var_y_dy (np.array) – gradient of the variance function/vector of the probabilistic regression model w.r.t. the regression model’s input

Returns:

d_log_lik_d_z (np.array) – gradient of the logpdf w.r.t. y_lf

static initialize_bmfia_iterator(coords_mat, time_vec, y_obs, bmfia_subiterator)[source]#

Initialize the bmfia iterator.

Parameters:
  • coords_mat (np.array) – Coordinates of the experimental data.

  • time_vec (np.array) – Time vector of the experimental data.

  • y_obs (np.array) – Experimental data observations at coordinates

  • bmfia_subiterator (bmfia_subiterator) – BMFIA subiterator object.

partial_grad_evaluate(forward_model_input, forward_model_output)[source]#

Implement the partial derivative of the evaluate method.

The partial derivative w.r.t. the output of the sub-model is for example required to calculate gradients of the current model w.r.t. to the sample input.

Parameters:
  • forward_model_input (np.array) – Sample inputs of the model run (here not required).

  • forward_model_output (np.array) – Output of the underlying sub- or forward model for the current batch of sample inputs.

Returns:

grad_out (np.array) – Evaluated partial derivative of the evaluation function w.r.t. the output of the underlying sub-model.

class BmfiaInterface(num_processors_multi_processing=1, probabilistic_mapping_type='per_coordinate')[source]#

Bases: object

Interface class for Bayesian multi-fidelity inverse analysis.

Interface for grouping the outputs of several simulation models with identical model inputs to one multi-fidelity data point in the multi-fidelity space.

num_processors_multi_processing#

Number of processors that should be used in the multi-processing pool.

Type:

int

evaluate_method#

Configured method to evaluate the probabilistic mapping

Type:

method

evaluate_and_gradient_method#

Configured method to evaluate the probabilistic mapping and its gradient

Type:

method

instantiate_probabilistic_mappings#

Configured method to instantiate the probabilistic mapping objects

Type:

method

probabilistic_mapping_obj_lst#

List of probabilistic mapping objects, which models the probabilistic dependency between high-fidelity model, low-fidelity models and informative input features for each coordinate tuple of \(y_{lf} \times y_{hf} \times \gamma_i\) individually.

Type:

lst

update_mappings_method#

Configured method to update the probabilistic mapping

Type:

method

coord_labels#

Labels / names of the coordinates in the experimental data file

Type:

str

time_vec#

Vector with time-stamps of observations

Type:

np.array

coords_mat#

Matrix with coordinate values for observations

Type:

np.array

Returns:

BmfiaInterface (obj) – Instance of the BmfiaInterface

build_approximation(z_lf_train, y_hf_train, approx, coord_labels, time_vec, coords_mat)[source]#

Build the probabilistic regression models.

Build and train the probabilistic mapping objects based on the training inputs \(\mathcal{D}_f={Y_{HF},Z_{LF}}\) per coordinate point/measurement point in the inverse problem.

Parameters:
  • z_lf_train (np.array) –

    Training inputs for probabilistic mapping.

    • Rows: Samples

    • Columns: Coordinates

  • y_hf_train (np.array) –

    Training outputs for probabilistic mapping.

    • Rows: Samples

    • Columns: Coordinates

  • approx (Model) – Probabilistic mapping in configuration dictionary.

  • coord_labels (list) – List of coordinate labels.

  • time_vec (np.array) – Time vector of the experimental data.

  • coords_mat (np.array) – (Spatial) Coordinates of the experimental data.

static check_coordinates_return_dimensions(z_lf, time_vec, coords_mat)[source]#

Check the compliance of Z_LF with the coordinates and time vector.

Parameters:
  • z_lf (np.array) – Low fidelity coordinates

  • time_vec (np.array) – Coordinates time vector

  • coords_mat (np.array) – (spatial) coordinates matrix

Returns:
  • num_coords (int) – number of coordinates in the current inverse problem

  • t_size (int) – number of time steps in the current inverse problem

evaluate(samples, support='y')[source]#

Map the lf-features to a probabilistic response for the hf model.

Calls the probabilistic mapping and predicts the mean and variance, respectively covariance, for the high-fidelity model, given the inputs z_lf (called samples here).

Parameters:
  • samples (np.array) –

    Low-fidelity feature vector z_lf that contains the corresponding Monte-Carlo points, on which the probabilistic mapping should be evaluated. Dimensions:

    • Rows: different multi-fidelity vector/points (each row is one multi-fidelity point)

    • Columns: different model outputs/informative features

  • support (str) – Support/variable for which we predict the mean and (co)variance. For support=f the Gaussian process predicts w.r.t. the latent function f. For the choice of support=y we predict w.r.t. the simulation/experimental output y

Returns:
  • mean (np.array) – Vector of mean predictions \(\mathbb{E}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*, \mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

  • variance (np.array) – Vector of variance predictions \(\mathbb{V}_{ f^*}[p(y_{HF}^*|f^*,z_{LF}^*,\mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

evaluate_and_gradient(z_lf, support='y')[source]#

Evaluate probabilistic mapping and its gradient.

Calls the probabilistic mapping and predicts the mean and variance, respectively covariance, for the high-fidelity model, given the inputs z_lf as well as its gradient w.r.t. the low-fidelity model.

Parameters:
  • z_lf (np.array) –

    Low-fidelity feature vector that contains the corresponding Monte-Carlo points, on which the probabilistic mapping should be evaluated. Dimensions:

    • Rows: different multi-fidelity vector/points (each row is one multi-fidelity point)

    • Columns: different model outputs/informative features

  • support (str) – Support/variable for which we predict the mean and (co)variance. For support=f the Gaussian process predicts w.r.t. the latent function f. For the choice of support=y we predict w.r.t. the simulation/experimental output y

Returns:
  • mean (np.array) – Vector of mean predictions \(\mathbb{E}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*, \mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

  • variance (np.array) – Vector of variance predictions \(\mathbb{V}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*,\mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

  • grad_mean (np.array, optional) – Gradient matrix for the mean prediction. Different HF predictions per row, and gradient vector entries per column

  • grad_variance (np.array, optional) – Gradient matrix for the mean prediction. Different HF predictions per row, and gradient vector entries per column

static evaluate_and_gradient_per_coordinate(z_lf, support, probabilistic_mapping_obj_lst, _time_vec, _coords_mat)[source]#

Evaluate probabilistic mapping and gradient for space point.

Here a probabilistic mapping per coordinate combination (time and space) is evaluated along with the gradient of the underlying probabilistic mapping.

Calls the probabilistic mapping and predicts the mean and variance, respectively covariance, for the high-fidelity model, given the inputs z_lf along with the gradients of the mean and the variance function of the underlying probabilistic mapping.

Parameters:
  • z_lf (np.array) – Low-fidelity feature vector that contains the corresponding Monte-Carlo points on which the probabilistic mapping should be evaluated. Dimensions: Rows: different multi-fidelity vector/points (each row is one multi-fidelity point). Columns: different model outputs/informative features. Note: z_lf might be a 3d tensor here Dims z_lf: gamma_dim x num_samples x coord_dim Dims z_lf.T: coord_dim x num_samples x gamma_dim –> iterate over coord_dim

  • support (str) – Support/variable for which we predict the mean and (co)variance. For support=f the Gaussian process predicts w.r.t. the latent function f. For the choice of support=y we predict w.r.t. to the simulation/experimental output y,

  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects

  • _time_vec (np.array) – Vector of time points

  • _coords_mat (np.array) – Matrix of spatial coordinates

Returns:
  • mean (np.array) – Vector of mean predictions

    \(\mathbb{E}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*, \mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

    • variance (np.array) – Vector of variance predictions \(\mathbb{V}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*,\mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

grad_mean (np.array): Gradient matrix for the mean prediction.

Different HF predictions per row, and gradient vector entries per column

grad_variance (np.array): Gradient matrix for the mean prediction.

Different HF predictions per row, and gradient vector entries per column

static evaluate_and_gradient_per_time_step(z_lf, support, probabilistic_mapping_obj_lst, time_vec, coords_mat)[source]#

Evaluate probabilistic mapping and gradient for time step.

Here a probabilistic mapping per time-step but for all locations combined is evaluated along with the gradient of the mean and variance function of the underlying probabilistic mapping.

Parameters:
  • z_lf (np.array) – Low-fidelity feature vector that contains the corresponding Monte Carlo points on which the probabilistic mapping should be evaluated. Dimensions: Rows: different multi-fidelity vector/points (each row is one multi-fidelity point). Columns: different model outputs/informative features. Note: z_lf might be a 3d tensor here Dims z_lf: gamma_dim x num_samples x coord_dim Dims z_lf.T: coord_dim x num_samples x gamma_dim –> iterate over coord_dim

  • support (str) – Support/variable for which we predict the mean and (co)variance. For support=f the Gaussian process predicts w.r.t. the latent function f. For the choice of support=y we predict w.r.t. to the simulation/experimental output y,

  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects.

  • time_vec (np.array) – Time vector for which the probabilistic mapping is evaluated.

  • coords_mat (np.array) – Coordinates for which the probabilistic mapping is evaluated.

Returns:
  • mean (np.array) – Vector of mean predictions

    \(\mathbb{E}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*, \mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

    • variance (np.array) – Vector of variance predictions \(\mathbb{V}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*,\mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

grad_mean (np.array): Gradient matrix for the mean prediction.

Different HF predictions per row, and gradient vector entries per column

grad_variance (np.array): Gradient matrix for the mean prediction.

Different HF predictions per row, and gradient vector entries per column

static evaluate_per_coordinate(z_lf, support, probabilistic_mapping_obj_lst, _time_vec, _coords_mat)[source]#

Map the lf features to a probabilistic response for the hf model.

Here a probabilistic mapping per coordinate combination (time and space) is evaluated.

Calls the probabilistic mapping and predicts the mean and variance, respectively covariance, for the high-fidelity model, given the inputs z_lf.

Parameters:
  • z_lf (np.array) – Low-fidelity feature vector that contains the corresponding Monte-Carlo points on which the probabilistic mapping should be evaluated. Dimensions: Rows: different multi-fidelity vector/points (each row is one multi-fidelity point). Columns: different model outputs/informative features.

  • support (str) – Support/variable for which we predict the mean and (co)variance. For support=f the Gaussian process predicts w.r.t. the latent function f. For the choice of support=y we predict w.r.t. to the simulation/experimental output y,

  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects.

  • _time_vec (np.array) – Time vector of the experimental data.

  • _coords_mat (np.array) – (Spatial) Coordinates of the experimental data.

Returns:
  • mean (np.array) – Vector of mean predictions \(\mathbb{E}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*, \mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

  • variance (np.array) – Vector of variance predictions \(\mathbb{V}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*,\mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

static evaluate_per_time_step(z_lf, support, probabilistic_mapping_obj_lst, time_vec, coords_mat)[source]#

Map the LF features to a probabilistic response for the hf model.

Here a probabilistic mapping per time-step but for all locations combined is evaluated.

Calls the probabilistic mapping and predicts the mean and variance, respectively covariance, for the high-fidelity model, given the inputs z_lf.

Parameters:
  • z_lf (np.array) – Low-fidelity feature vector that contains the corresponding Monte-Carlo points on which the probabilistic mapping should be evaluated. Dimensions: Rows: different multi-fidelity vector/points (each row is one multi-fidelity point). Columns: different model outputs/informative features. Note: z_lf might be a 3d tensor here Dims z_lf: gamma_dim x num_samples x coord_dim Dims z_lf.T: coord_dim x num_samples x gamma_dim –> iterate over coord_dim (= combines space and time, in the order of batches per time step)

  • support (str) – Support/variable for which we predict the mean and (co)variance. For support=f the Gaussian process predicts w.r.t. the latent function f. For the choice of support=y we predict w.r.t. to the simulation/experimental output y,

  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects.

  • time_vec (np.array) – Vector of time coordinate points.

  • coords_mat (np.array) – Matrix of spatial coordinate points.

Returns:
  • mean (np.array) – Vector of mean predictions \(\mathbb{E}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*, \mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

  • variance (np.array) – Vector of variance predictions \(\mathbb{V}_{f^*}[p(y_{HF}^*|f^*,z_{LF}^*,\mathcal{D}_{f})]\) for the HF model given the low-fidelity feature input. Different HF predictions per row. Each row corresponds to one multi-fidelity input vector in \(\Omega_{y_{lf}\times\gamma_i}\).

static instantiate_per_coordinate(z_lf_train, y_hf_train, _time_vec, _coords_mat, approx)[source]#

Instantiate probabilistic mappings per coordinate.

Parameters:
  • z_lf_train (np.array) – Training inputs for probabilistic mapping. Rows: Samples, Columns: Coordinates

  • y_hf_train (np.array) – Training outputs for probabilistic mapping. Rows: Samples, Columns: Coordinates

  • _time_vec (np.array) – Time vector of the experimental data.

  • _coords_mat (np.array) – (Spatial) Coordinates of the experimental data.

  • approx (Model) – Probabilistic mapping

Returns:
  • z_lf_train (np.array) – Input matrix in correct ordering

  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects

static instantiate_per_time_step(z_lf_train, y_hf_train, time_vec, coords_mat, approx)[source]#

Instantiate probabilistic mappings per time step.

This means that one probabilistic mapping is build for all space locations combined but different mappings per time instance.

Parameters:
  • z_lf_train (np.array) – Training inputs for probabilistic mapping. Rows: Samples, Columns: Coordinates

  • y_hf_train (np.array) – Training outputs for probabilistic mapping. Rows: Samples, Columns: Coordinates

  • time_vec (np.array) – Time vector of the experimental data.

  • coords_mat (np.array) – (Spatial) Coordinates of the experimental data.

  • approx (Model) – Probabilistic mapping

Returns:

z_lf_array (np.array) – Input matrix in correct ordering

static iterate_over_time_steps(z_lf_array, support, num_coords, probabilistic_mapping_obj_lst, gradient_bool=None)[source]#

Iterate and arrange data over different time steps.

Evaluate and iterate over the regression models for the time steps.

Parameters:
  • z_lf_array (np.array) – Low fidelity variables after reshaping

  • support (np.array) – Support of the random variable

  • num_coords (int) – Number of coordinates

  • probabilistic_mapping_obj_lst (lst) – List of probabilistic mapping objects

  • gradient_bool (bool, optional) – If True, the gradient of the mean and variance is returned

Returns:
  • mean (np.array) – Mean of the high fidelity variables

  • variance (np.array) – Variance of the high fidelity variables

  • grad_mean (np.array) – Gradient of the mean

  • grad_variance (np.array) – Gradient of the variance

static optimize_hyper_params(probabilistic_mapping)[source]#

Train one probabilistic surrogate model.

Parameters:

probabilistic_mapping (obj) – Instantiated but untrained probabilistic mapping

Returns:

optimized_mapping_state_dict (dict) – Dictionary with optimized state of the trained probabilistic regression model

static prepare_z_lf_for_time_steps(z_lf, t_size, coords_mat)[source]#

Prepare the low fidelity coordinates for the time steps.

Parameters:
  • z_lf (np.array) – Low fidelity variables before reshaping

  • t_size (int) – number of time steps in the current inverse problem

  • coords_mat (np.array) – (spatial) coordinates matrix

Returns:

z_lf_out (np.array) – Low fidelity variables after reshaping

set_optimized_state_of_probabilistic_mappings(optimized_mapping_states_lst)[source]#

Set the new states of the trained probabilistic mappings.

Parameters:

optimized_mapping_states_lst (lst) – List of updated / trained states for the probabilistic regression models.

static train_probabilistic_mappings_in_parallel(num_coords, num_processors_multi_processing, probabilistic_mapping_obj_lst)[source]#

Train the probabilistic regression models in parallel.

We use a multi-processing tool to conduct the training of the probabilistic regression models in parallel.

Parameters:
  • num_coords (int) – number of coordinates in the current inverse problem

  • num_processors_multi_processing (int) – number of processors to use for the multi-processing pool

  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects

Returns:

optimized_mapping_states_lst (lst) – List of updated / trained states for the probabilistic regression models.

static update_mappings_per_coordinate(probabilistic_mapping_obj_lst, z_lf_train, y_hf_train, _time_vec, _coords_mat)[source]#

Update the probabilistic mappings per coordinate.

Parameters:
  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects

  • z_lf_train (np.array) – Training inputs for probabilistic mapping.

  • y_hf_train (np.array) – Training outputs for probabilistic mapping.

  • _time_vec (np.array) – Time vector for which the probabilistic mapping is evaluated.

  • _coords_mat (np.array) – Coordinates for which the probabilistic mapping is evaluated.

Returns:
  • z_lf_train (np.array) – Training inputs for probabilistic mapping.

  • y_hf_train (np.array) – Training outputs for probabilistic mapping.

  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects

static update_mappings_per_time_step(probabilistic_mapping_obj_lst, z_lf_array, y_hf_array, time_vec, coords_mat)[source]#

Update the probabilistic mappings per time step.

Parameters:
  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects

  • z_lf_array (np.array) – Input matrix in correct ordering

  • y_hf_array (np.array) – Output matrix in correct ordering

  • time_vec (np.array) – Time vector for which the probabilistic mapping is evaluated.

  • coords_mat (np.array) – Coordinates for which the probabilistic mapping is evaluated.

Returns:
  • z_lf_train (np.array) – Training inputs for probabilistic mapping.

  • y_hf_train (np.array) – Training outputs for probabilistic mapping.

  • probabilistic_mapping_obj_lst (list) – List of probabilistic mapping objects

valid_probabilistic_mappings_configurations = {'per_coordinate': (<staticmethod(<function BmfiaInterface.instantiate_per_coordinate>)>, <staticmethod(<function BmfiaInterface.evaluate_per_coordinate>)>, <staticmethod(<function BmfiaInterface.evaluate_and_gradient_per_coordinate>)>, <staticmethod(<function BmfiaInterface.update_mappings_per_coordinate>)>), 'per_time_step': (<staticmethod(<function BmfiaInterface.instantiate_per_time_step>)>, <staticmethod(<function BmfiaInterface.evaluate_per_time_step>)>, <staticmethod(<function BmfiaInterface.evaluate_and_gradient_per_time_step>)>, <staticmethod(<function BmfiaInterface.update_mappings_per_time_step>)>)}#

queens.models.likelihood_models.gaussian_likelihood module#

Gaussian likelihood.

class GaussianLikelihood(forward_model, noise_type, noise_value=None, nugget_noise_variance=0, noise_var_iterative_averaging=None, y_obs=None, experimental_data_reader=None)[source]#

Bases: LikelihoodModel

Gaussian likelihood model with fixed or dynamic noise.

The noise can be modelled by a full covariance matrix, independent variances or a unified variance for all observations. If the noise is chosen to be dynamic, a MAP estimate of the covariance, independent variances or unified variance is computed using a Jeffrey’s prior. Jeffrey’s prior is defined as \(\pi_J(\Sigma) = |\Sigma|^{-(p+2)/2}\), where \(\Sigma\) is the covariance matrix of shape \(p \times p\) (see [1])

References

[1]: Sun, Dongchu, and James O. Berger. “Objective Bayesian analysis for the multivariate

normal model.” Bayesian Statistics 8 (2007): 525-562.

nugget_noise_variance#

Lower bound for the likelihood noise parameter

Type:

float

noise_type#

String encoding the type of likelihood noise model: Fixed or MAP estimate with Jeffreys prior

Type:

str

noise_var_iterative_averaging#

Iterative averaging object

Type:

obj

normal_distribution#

Underlying normal distribution object

Type:

obj

Returns:

Instance of GaussianLikelihood Class

evaluate(samples)[source]#

Evaluate likelihood with current set of input samples.

Parameters:

samples (np.array) – Input samples

Returns:

dict – log-likelihood values at input samples

grad(samples, upstream_gradient)[source]#

Evaluate gradient of model w.r.t. current set of input samples.

Consider current model f(x) with input samples x, and upstream function g(f). The provided upstream gradient is \(\frac{\partial g}{\partial f}\) and the method returns \(\frac{\partial g}{\partial f} \frac{df}{dx}\).

Parameters:
  • samples (np.array) – Input samples

  • upstream_gradient (np.array) – Upstream gradient function evaluated at input samples \(\frac{\partial g}{\partial f}\)

Returns:

gradient (np.array) – Gradient w.r.t. current set of input samples \(\frac{\partial g}{\partial f} \frac{df}{dx}\)

update_covariance(y_model)[source]#

Update covariance matrix of the gaussian likelihood.

Parameters:

y_model (np.ndarray) – Forward model output with shape (samples, outputs)

queens.models.likelihood_models.likelihood_model module#

Module to define likelihood functions.

class LikelihoodModel(forward_model, y_obs)[source]#

Bases: Model

Base class for likelihood models.

forward_model#

Forward model on which the likelihood model is based

Type:

obj

y_obs#

Observation data

Type:

np.array

abstract evaluate(samples)[source]#

Evaluate model with current set of input samples.

Parameters:

samples (np.ndarray) – Input samples

abstract grad(samples, upstream_gradient)[source]#

Evaluate gradient of model w.r.t. current set of input samples.

Consider current model f(x) with input samples x, and upstream function g(f). The provided upstream gradient is \(\frac{\partial g}{\partial f}\) and the method returns \(\frac{\partial g}{\partial f} \frac{df}{dx}\).

Parameters:
  • samples (np.array) – Input samples

  • upstream_gradient (np.array) – Upstream gradient function evaluated at input samples \(\frac{\partial g}{\partial f}\)

Returns:

gradient (np.array) – Gradient w.r.t. current set of input samples \(\frac{\partial g}{\partial f} \frac{df}{dx}\)