Normal#

class hmclab.Distributions.Normal(*args, **kwargs)[source]#

Bases: hmclab.Distributions.base._AbstractDistribution

Normal distribution in model space.

Parameters
  • dimensions (int) – Dimension of the distribution.

  • means (numpy.ndarray) – Numpy array shaped as (dimensions, 1) containing the means of the distribution.

  • covariance (numpy.ndarray) – Numpy array shaped as either as (dimensions, dimensions) or (dimensions, 1). This array represents either the full covariance matrix for a multivariate Gaussian, or an column vector with variances for dimensions separate uncorrelated Gaussians.

  • lower_bounds (numpy.ndarray) – Numpy array of shape (dimensions, 1) that contains the lower limits of each parameter.

  • upper_bounds (numpy.ndarray) – Numpy array of shape (dimensions, 1) that contains the upper limits of each parameter.

__init__(means: numpy.ndarray, covariance: Optional[Union[numpy.ndarray, float]], inverse_covariance: Optional[Union[numpy.ndarray, float]] = None, lower_bounds: Optional[numpy.ndarray] = None, upper_bounds: Optional[numpy.ndarray] = None)[source]#

Methods

__init__

corrector

Correct HMC trajectory.

create_default

dimensions

Dimensionality of misfit space.

generate

gradient

Method to compute the gradient of the distribution.

misfit

Method to compute the misfit of a Normal distribution distribution.

misfit_bounds

Compute misfit of bounded distribution.

normalize

update_bounds

Update bounded distribution.

Attributes

lower_bounds

Lower bounds for every parameter.

name

Name of the distribution.

normalized

Boolean describing if the distribution is normalized.

upper_bounds

Upper bounds for every parameter.

diagonal

Indicator whether or not the covariance matrix is diagonal, i.e. if the distribution is uncorrelated.

means

Means in model space

covariance

Covariance matrix in model space

inverse_covariance

Inverse covariance matrix

normalization_constant

Covariance matrix determinant and dimensionality factored in single likelihood term.

dimensions() int#

Dimensionality of misfit space.

This is an abstract parameter. If it is not defined either in your class directly or in its constructor (the __init__ function) then attempting to use the class will raise a NotImplementedError.

Access it like a parameter, not a function: distribution.dimensions.

normalization_constant#

Covariance matrix determinant and dimensionality factored in single likelihood term. Uncomputed if normalized() is never called.

means: numpy.ndarray#

Means in model space

covariance: numpy.ndarray#

Covariance matrix in model space

inverse_covariance: numpy.ndarray#

Inverse covariance matrix

diagonal: bool#

Indicator whether or not the covariance matrix is diagonal, i.e. if the distribution is uncorrelated.

misfit(coordinates: numpy.ndarray) float[source]#

Method to compute the misfit of a Normal distribution distribution.

gradient(coordinates: numpy.ndarray) numpy.ndarray[source]#

Method to compute the gradient of the distribution.

corrector(coordinates: numpy.ndarray, momentum: numpy.ndarray)#

Correct HMC trajectory.

Method to correct an HMC particle for bounded distributions, which is called after every time integration step.

Parameters
  • coordinates (numpy.ndarray) – Numpy array shaped as (dimensions, 1) representing a column vector containing the coordinates \(\mathbf{m}\) upon which to operate by reference.

  • momentum (numpy.ndarray) – Numpy array shaped as (dimensions, 1) representing a column vector containing the momenta \(\mathbf{p}\) upon which to operate by reference.

misfit_bounds(coordinates: numpy.ndarray) float#

Compute misfit of bounded distribution.

Method to compute the misfit associated with the truncated part of the distribution. Used internally.

update_bounds(lower: Optional[numpy.ndarray] = None, upper: Optional[numpy.ndarray] = None)#

Update bounded distribution.

This method updates the bounds of a distribution. Note that invocating it, does not require both bounds to be passed.

If both vectors are passed, ensure that all upper bounds are above the corresponding lower bounds.

Parameters
  • lower (numpy.ndarray or None) – Either an array shaped as (dimensions, 1) with floats for the lower bounds, or None for no bounds. If some dimensions should be bounded, while others should not, use -numpy.inf within the vector as needed.

  • upper (numpy.ndarray or None) – Either an array shaped as (dimensions, 1) with floats for the upper bounds, or None for no bounds. If some dimensions should be bounded, while others should not, use numpy.inf within the vector as needed.

Raises

ValueError – A ValueError is raised if the supplied upper and lower bounds are incompatible.