nifty8.operators.sampling_enabler module#

class SamplingEnabler(likelihood, prior, iteration_controller, approximation=None, start_from_zero=False)[source]#

Bases: EndomorphicOperator

Class which acts as a operator object built of (likelihood + prior) and enables sampling from its inverse even if the operator object itself does not support it.

Parameters:
  • likelihood (EndomorphicOperator) – Metric of the likelihood

  • prior (EndomorphicOperator) – Metric of the prior

  • iteration_controller (IterationController) – The iteration controller to use for the iterative numerical inversion done by a ConjugateGradient object.

  • approximation (LinearOperator, optional) – if not None, this linear operator should be an approximation to the operator, which supports the operation modes that the operator doesn’t have. It is used as a preconditioner during the iterative inversion, to accelerate convergence.

  • start_from_zero (boolean) – If true, the conjugate gradient algorithm starts from a field filled with zeros. Otherwise, it starts from a prior samples. Default is False.

__init__(likelihood, prior, iteration_controller, approximation=None, start_from_zero=False)[source]#
__repr__()[source]#

Return repr(self).

draw_sample(from_inverse=False)[source]#

Generates a sample from a Gaussian distribution with zero mean and covariance given by the operator.

May or may not be implemented. Only optional.

Parameters:

from_inverse (bool (default : False)) – if True, the sample is drawn from the inverse of the operator

Returns:

A sample from the Gaussian of given covariance.

Return type:

nifty8.field.Field or nifty8.multi_field.MultiField

special_draw_sample(from_inverse=False)[source]#