EllipsoidDomain#

Module for the Ellipsoid Domain.

class EllipsoidDomain(ellipsoid_dict, sample_surface=False)[source]

Bases: DomainInterface

Implementation of the ellipsoid domain.

Initialization of the EllipsoidDomain class.

Parameters:
  • ellipsoid_dict (dict) – A dictionary where the keys are the variable names and the values are the domain extrema.

  • sample_surface (bool) – A flag to choose the sampling strategy. If True, samples are taken from the surface of the ellipsoid. If False, samples are taken from the interior of the ellipsoid. Default is False.

Raises:

TypeError – If the input dictionary is not correctly formatted.

Warning

Sampling for dimensions greater or equal to 10 could result in a shrinkage of the ellipsoid, which degrades the quality of the samples. For dimensions higher than 10, see the following reference.

See also

Original reference: Dezert, Jean, and Musso, Christian. An efficient method for generating points uniformly distributed in hyperellipsoids. Proceedings of the Workshop on Estimation, Tracking and Fusion: A Tribute to Yaakov Bar-Shalom. 2001.

Example:
>>> spatial_domain = Ellipsoid({'x':[-1, 1], 'y':[-1,1]})
property sample_modes

List of available sampling modes.

Returns:

List of available sampling modes.

Return type:

list[str]

property variables

List of variables of the domain.

Returns:

List of variables of the domain.

Return type:

list[str]

is_inside(point, check_border=False)[source]

Check if a point is inside the ellipsoid.

Parameters:
  • point (LabelTensor) – Point to be checked.

  • check_border (bool) – If True, the border is considered inside the ellipsoid. Default is False.

Raises:

ValueError – If the labels of the point are different from those passed in the __init__ method.

Returns:

True if the point is inside the domain, False otherwise.

Return type:

bool

Note

When sample_surface=True in the __init__ method, this method checks only those points lying on the surface of the ellipsoid.

sample(n, mode='random', variables='all')[source]

Sampling routine.

Parameters:
  • n (int) – Number of points to sample.

  • mode (str) – Sampling method. Default is random. Available modes: random sampling, random.

  • variables (list[str]) – variables to be sampled. Default is all.

Raises:

NotImplementedError – If the sampling mode is not implemented.

Returns:

Sampled points.

Return type:

LabelTensor

Example:
>>> ellipsoid = Ellipsoid({'x':[1, 0], 'y':1})
>>> ellipsoid.sample(n=6)
    tensor([[0.4872, 1.0000],
            [0.2977, 1.0000],
            [0.0422, 1.0000],
            [0.6431, 1.0000],
            [0.7272, 1.0000],
            [0.8326, 1.0000]])