Himmelblau#

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

Bases: hmclab.Distributions.base._AbstractDistribution

Himmelblau’s 2-dimensional function.

Himmelblau’s function is defined as:

\[f(x,y)=(x^{2}+y-11)^{2}+(x+y^{2}-7)^{2}\]
__init__(temperature: float = 1)[source]#

Methods

__init__

corrector

Correct HMC trajectory.

create_default

generate

gradient

Returns a numpy.ndarray shaped as (dimensions, 1) containing the gradient of Himmelblau's function at the given coordinates.

misfit

Returns the value of Himmelblau's function at the given coordinates.

misfit_bounds

Compute misfit of bounded distribution.

normalize

Normalize distribution.

update_bounds

Update bounded distribution.

Attributes

dimensions

lower_bounds

Lower bounds for every parameter.

name

Name of the distribution.

normalized

Boolean describing if the distribution is normalized.

temperature

Float representing the temperature (or annealing, \(T\)) of Himmelblau's function.

upper_bounds

Upper bounds for every parameter.

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.

normalize()#

Normalize distribution.

Method to compute the normalization constant of a distribution. As this might take significant time, it is not done in initialization.

Raises

AttributeError – An AttributeError is raised if the distribution provides no way to be normalized, e.g. when the normalization constant is intractable.

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.

temperature: float = 1#

Float representing the temperature (or annealing, \(T\)) of Himmelblau’s function.

Alters the misfit function in the following way:

\[f(x,y)_T=\frac{f(x,y)}{T}\]
misfit(coordinates: numpy.ndarray) float[source]#

Returns the value of Himmelblau’s function at the given coordinates.

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

Returns a numpy.ndarray shaped as (dimensions, 1) containing the gradient of Himmelblau’s function at the given coordinates.