nifty8.library.special_distributions module#

class GammaOperator(domain, alpha=None, beta=None, theta=None, mean=None, var=None, delta=0.01)[source]#

Bases: Operator

Transform a standard normal into a gamma distribution.

The pdf of the gamma distribution is defined as follows:

\frac{1}{\Gamma(k)\theta^k} x^{k-1}
\exp \left( -\frac{x}{\theta} \right)

This transformation is implemented as a linear interpolation which maps a Gaussian onto a gamma distribution.

Parameters:
  • domain (Domain, tuple of Domain or DomainTuple) – The domain on which the field shall be defined. This is at the same time the domain and the target of the operator.

  • alpha (float) – The shape parameter of the gamma distribution.

  • beta (float or nifty8.field.Field) – The rate parameter of the gamma distribution.

  • theta (float or nifty8.field.Field) – The scale parameter of the gamma distribution.

  • mean (float) – Mean of the gamma distribution.

  • var (float) – Variance of the gamma distribution.

  • delta (float) – Distance between sampling points for linear interpolation.

__init__(domain, alpha=None, beta=None, theta=None, mean=None, var=None, delta=0.01)[source]#
property alpha#

The value of the shape-parameter of the gamma distribution

Type:

float

apply(x)[source]#

Applies the operator to a Field, MultiField or Linearization.

Parameters:

x (nifty8.field.Field, nifty8.multi_field.MultiField,) – or nifty8.linearization.Linearization Input on which the operator shall act. Needs to be defined on domain. If x`is a :class:`nifty8.linearization.Linearization, apply returns a new nifty8.linearization.Linearization contining the result of the operator application as well as its Jacobian, evaluated at x.

property beta#

The value of rate parameter of the gamma distribution

Type:

float

property mean#

The value of the mean of the gamma distribution.

Type:

float

property mode#

The value of the mode of the gamma distribution. Exists for alpha >= 1 or k >= 1.

Type:

float

property theta#

The value of scale parameter of the gamma distribution

Type:

float

property var#

The value of the variance of the gamma distribution.

Type:

float

class InverseGammaOperator(domain, alpha=None, q=None, delta=0.01, mode=None, mean=None)[source]#

Bases: Operator

Transform a standard normal into an inverse gamma distribution.

The pdf of the inverse gamma distribution is defined as follows:

\frac{q^\alpha}{\Gamma(\alpha)}x^{-\alpha -1}
\exp \left(-\frac{q}{x}\right)

That means that for large x the pdf falls off like x^{(-\alpha -1)}. The mean of the pdf is at q / (\alpha - 1) if \alpha > 1. The mode is q / (\alpha + 1).

The operator can be initialized by setting either alpha and q or mode and mean. In accordance to the statements above the mean must be greater than the mode. Otherwise would get alpha < 0 and so no mean would be defined.

This transformation is implemented as a linear interpolation which maps a Gaussian onto an inverse gamma distribution.

Parameters:
  • domain (Domain, tuple of Domain or DomainTuple) – The domain on which the field shall be defined. This is at the same time the domain and the target of the operator.

  • alpha (float) – The alpha-parameter of the inverse-gamma distribution.

  • q (float or nifty8.field.Field) – The q-parameter of the inverse-gamma distribution.

  • mode (float) – The mode of the inverse-gamma distribution.

  • mean (float) – The mean of the inverse-gamma distribution.

  • delta (float) – Distance between sampling points for linear interpolation.

__init__(domain, alpha=None, q=None, delta=0.01, mode=None, mean=None)[source]#
property alpha#

The value of the alpha-parameter of the inverse-gamma distribution

Type:

float

apply(x)[source]#

Applies the operator to a Field, MultiField or Linearization.

Parameters:

x (nifty8.field.Field, nifty8.multi_field.MultiField,) – or nifty8.linearization.Linearization Input on which the operator shall act. Needs to be defined on domain. If x`is a :class:`nifty8.linearization.Linearization, apply returns a new nifty8.linearization.Linearization contining the result of the operator application as well as its Jacobian, evaluated at x.

property mean#

The value of the mean of the inverse-gamma distribution. Only existing for alpha > 1.

Type:

float

property mode#

The value of the mode of the inverse-gamma distribution

Type:

float

property q#

The value of q-parameters of the inverse-gamma distribution

Type:

float

property var#

The value of the variance of the inverse-gamma distribution. Only existing for alpha > 2.

Type:

float

class LaplaceOperator(domain, loc=0, scale=1)[source]#

Bases: Operator

Transform a standard normal to a Laplace distribution.

Parameters:
  • domain (Domain, tuple of Domain or DomainTuple) – The domain on which the field shall be defined. This is at the same time the domain and the target of the operator.

  • loc (float)

  • scale (float)

__init__(domain, loc=0, scale=1)[source]#
apply(x)[source]#

Applies the operator to a Field, MultiField or Linearization.

Parameters:

x (nifty8.field.Field, nifty8.multi_field.MultiField,) – or nifty8.linearization.Linearization Input on which the operator shall act. Needs to be defined on domain. If x`is a :class:`nifty8.linearization.Linearization, apply returns a new nifty8.linearization.Linearization contining the result of the operator application as well as its Jacobian, evaluated at x.

inverse(x)[source]#
LogInverseGammaOperator(domain, alpha, q, delta=0.01)[source]#

Transform a standard normal into the log of an inverse gamma distribution.

class UniformOperator(domain, loc=0, scale=1)[source]#

Bases: Operator

Transform a standard normal into a uniform distribution.

The uniform distribution’s support is [loc, loc + scale].

Parameters:
  • domain (Domain, tuple of Domain or DomainTuple) – The domain on which the field shall be defined. This is at the same time the domain and the target of the operator.

  • loc (float)

  • scale (float)

__init__(domain, loc=0, scale=1)[source]#
apply(x)[source]#

Applies the operator to a Field, MultiField or Linearization.

Parameters:

x (nifty8.field.Field, nifty8.multi_field.MultiField,) – or nifty8.linearization.Linearization Input on which the operator shall act. Needs to be defined on domain. If x`is a :class:`nifty8.linearization.Linearization, apply returns a new nifty8.linearization.Linearization contining the result of the operator application as well as its Jacobian, evaluated at x.

inverse(field)[source]#