## Module contents¶

Integration measures.

Bases: object

A box domain defined by a hyper-cube.

Parameters
property bounds: List[Tuple[float, float]]

The bounds defining the hypercube.

Return type
convert_to_list_of_continuous_parameters()

Converts the box bounds into a list of ContinuousParameter objects.

Return type
Returns

The continuous parameters (one for each dimension of the box).

Bases: object

An abstract class for an integration measure defined by a density.

Parameters
property input_dim

The input dimensionality.

property can_sample: bool

Indicates whether the measure has sampling available.

Return type

bool

Returns

True if sampling is available. False otherwise.

compute_density(x)

Evaluates the density at x.

Parameters

x (ndarray) – Points at which density is evaluated, shape (n_points, input_dim).

Return type

ndarray

Returns

The density at x, shape (n_points, ).

Evaluates the gradient of the density at x.

Parameters

x (ndarray) – Points at which the gradient is evaluated, shape (n_points, input_dim).

Return type

ndarray

Returns

The gradient of the density at x, shape (n_points, input_dim).

reasonable_box()

A reasonable box containing the measure.

Outside this box, the measure should be zero or virtually zero.

Return type
Returns

The reasonable box.

sample(num_samples, context_manager=None)

Samples from the measure.

Parameters
Return type

ndarray

Returns

The samples, shape (num_samples, input_dim).

The Gaussian measure.

The Gaussian measure has density

$p(x)=(2\pi)^{-\frac{d}{2}} \left(\prod_{j=1}^d \sigma_j^2\right)^{-\frac{1}{2}} e^{-\frac{1}{2}\sum_{i=1}^d\frac{(x_i-\mu_i)^2}{\sigma_i^2}}$

where $$\mu_i$$ is the $$i$$ th element of the mean parameter and $$\sigma_i^2$$ is $$i$$ th element of the variance parameter.

Parameters
• mean (ndarray) – The mean of the Gaussian measure, shape (input_dim, ).

• variance (Union[float, ndarray]) – The variances of the Gaussian measure, shape (input_dim, ). If a scalar value is given, all dimensions will have same variance.

Raises
• TypeError – If mean is not of type ndarray.

• ValueError – If mean is not of dimension 1.

• TypeError – If variance is neither of type float nor of type ndarray.

• ValueError – If variance is of type float but is non-positive.

• ValueError – If variance is of type ndarray but of other size than mean.

• ValueError – If variance is of type ndarray and any of its elements is non-positive.

property input_dim

The input dimensionality.

property full_covariance_matrix

The full covariance matrix of the Gaussian measure.

property can_sample: bool

Indicates whether the measure has sampling available.

Return type

bool

Returns

True if sampling is available. False otherwise.

compute_density(x)

Evaluates the density at x.

Parameters

x (ndarray) – Points at which density is evaluated, shape (n_points, input_dim).

Return type

ndarray

Returns

The density at x, shape (n_points, ).

Evaluates the gradient of the density at x.

Parameters

x (ndarray) – Points at which the gradient is evaluated, shape (n_points, input_dim).

Return type

ndarray

Returns

The gradient of the density at x, shape (n_points, input_dim).

reasonable_box()

A reasonable box containing the measure.

Outside this box, the measure should be zero or virtually zero.

Return type
Returns

The reasonable box.

sample(num_samples, context_manager=None)

Samples from the measure.

Parameters
Return type

ndarray

Returns

The samples, shape (num_samples, input_dim).

The Lebesgue measure.

The Lebesgue measure has density

$\begin{split}p(x)=\begin{cases} \hat{p} & x\in\text{domain}\\0 &\text{otherwise}\end{cases}.\end{split}$

The value $$\hat{p} = 1$$ if the parameter normalized is set to False and $$\hat{p} = |\text{domain}|^{-1}$$ otherwise, where $$|\text{domain}|$$ is the volume (un-normalized Lebesgue measure) of the domain.

Parameters
Raises

NumericalPrecisionError – If normalized=True this excetion can be raised if the volume of the domain is so small that it is numerically zero or even negative.

property input_dim

The input dimensionality.

property can_sample: bool

Indicates whether the measure has sampling available.

Return type

bool

Returns

True if sampling is available. False otherwise.

compute_density(x)

Evaluates the density at x.

Parameters

x (ndarray) – Points at which density is evaluated, shape (n_points, input_dim).

Return type

ndarray

Returns

The density at x, shape (n_points, ).

Evaluates the gradient of the density at x.

Parameters

x (ndarray) – Points at which the gradient is evaluated, shape (n_points, input_dim).

Return type

ndarray

Returns

The gradient of the density at x, shape (n_points, input_dim).

reasonable_box()

A reasonable box containing the measure.

Outside this box, the measure should be zero or virtually zero.

Return type
Returns

The reasonable box.

sample(num_samples, context_manager=None)

Samples from the measure.

Parameters
Return type

ndarray

Returns

The samples, shape (num_samples, input_dim).

classmethod from_bounds(bounds, normalized=False)

Creates and instance of this class from integration bounds.

Parameters
Returns

An instance of LebesgueMeasure.