Model¶
model
¶
Abstract Base classes that models should implement to be used for MCMC sampling.
The implementations of MCMC algorithms are based on (Cotter et al., 2013), We sample from a measure \(\mu\) that is defined via it's Radon-Nikodym derivative w.r.t. to a Gaussian reference measure.
where \(\mu_0 = \mathcal{N}(0, C)\) is a centered Gaussian reference measure with covariance operator \(C\). The likelihood is then given via the potential \(\Phi(u)\). Models should at least implement calculating the potential \(\Phi(u)\) and the action (i.e. matrix vector product in the finite dimensional setting) of the covariance operator \(C\) on a vector. The covariace operator is also sometimes called preconditioner.
Classes:
| Name | Description |
|---|---|
MCMCModel |
Abstract base class for an MCMC model that evaluates the likelihood |
DifferentiableMCMCModel |
Abstract base class for an MCMC model that evaluates the likelihood and also derivative information on the potential of the likelihood |
References: Cotter, Roberts, Stuart, White (2013). MCMC Methods for Functions: Modifying Old Algorithms to Make Them Faster. Statistical Science 28(3).
ls_mcmc.model.MCMCModel
¶
Bases: ABC
Base interface for MCMC target models.
Methods:
| Name | Description |
|---|---|
evaluate_potential |
Compute potential of likelihood |
compute_preconditioner_sqrt_action |
Apply preconditioner on a state |
reference_point |
Reference point that can be used to make sampling more effective |
reference_point
abstractmethod
property
¶
Return a reference point.
evaluate_potential
abstractmethod
¶
Return potential energy \(\Phi(u)\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
np.ndarray[tuple[int], np.dtype[np.floating]]
|
state \(u\). |
required |
compute_preconditioner_sqrt_action
abstractmethod
¶
compute_preconditioner_sqrt_action(state: np.ndarray[tuple[int], np.dtype[np.floating]]) -> np.ndarray[tuple[int], np.dtype[np.floating]]
Apply square-root preconditioner to state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
np.ndarray[tuple[int], np.dtype[np.floating]]
|
state \(u\). |
required |
ls_mcmc.model.DifferentiableMCMCModel
¶
Bases: MCMCModel
Extension of MCMCModel with differentiable potential.
Methods:
| Name | Description |
|---|---|
evaluate_potential |
Compute potential of likelihood |
compute_preconditioner_sqrt_action |
Apply square root of preconditioner on a state |
reference_point |
Reference point that can be used to make sampling more effective |
evaluate_gradient_of_potential |
Compute the gradient of the potential of the likelihood |
compute_preconditioner_action |
Apply preconditioner on a state |
evaluate_gradient_of_potential
abstractmethod
¶
evaluate_gradient_of_potential(state: np.ndarray[tuple[int], np.dtype[np.floating]]) -> np.ndarray[tuple[int], np.dtype[np.floating]]
Return gradient \(\nabla\Phi(u)\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
np.ndarray[tuple[int], np.dtype[np.floating]]
|
state \(u\). |
required |
compute_preconditioner_action
¶
compute_preconditioner_action(state: np.ndarray[tuple[int], np.dtype[np.floating]]) -> np.ndarray[tuple[int], np.dtype[np.floating]]
Apply full preconditioner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
np.ndarray[tuple[int], np.dtype[np.floating]]
|
state \(u\). |
required |