EllipsoidDomain#

Module for the Ellipsoid Domain.

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

Bases: BaseDomain

Implementation of the ellipsoid domain.

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:
>>> ellipsoid_domain = EllipsoidDomain({'x':[-1, 1], 'y':[-1, 1]})
>>> ellipsoid_domain = EllipsoidDomain({'x':[-1, 1], 'y':1.0})

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. The domain extrema can be either a list or tuple with two elements or a single number. If the domain extrema is a single number, the variable is fixed to that value.

  • sample_surface (bool) – If True, only the surface of the ellipsoid is considered part of the domain. Default is False.

Raises:
  • ValueError – If sample_surface is not a boolean.

  • TypeError – If the ellipsoid dictionary is not a dictionary.

  • ValueError – If the ellipsoid dictionary contains variables with invalid ranges.

  • ValueError – If the ellipsoid dictionary contains values that are neither numbers nor lists/tuples of numbers of length 2.

compute_center_axes()[source]

Compute centers and axes for the ellipsoid.

is_inside(point, check_border=False)[source]

Check if a point is inside the ellipsoid.

Parameters:
  • point (LabelTensor) – The point to check.

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

Raises:
  • ValueError – If point is not a LabelTensor.

  • ValueError – If the labels of point differ from the variables of the domain.

Returns:

Whether the point is inside the domain or not.

Return type:

bool

update(domain)[source]

Update the current domain by adding the labels contained in domain. Each new label introduces a new dimension. Only domains of the same type can be used for update.

Parameters:

domain (EllipsoidDomain) – The domain whose labels are to be merged into the current one.

Raises:

TypeError – If the provided domain is not of an instance of EllipsoidDomain.

Returns:

A new domain instance with the merged labels.

Return type:

EllipsoidDomain

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

Sampling routine.

Parameters:
  • n (int) – The number of samples to generate.

  • mode (str) – The sampling method. Available modes: random for random sampling. Default is random.

  • variables (list[str] | str) – The list of variables to sample. If all, all variables are sampled. Default is all.

Raises:
  • AssertionError – If n is not a positive integer.

  • ValueError – If the sampling mode is invalid.

  • ValueError – If variables is neither all, a string, nor a list/tuple of strings.

  • ValueError – If any of the specified variables is unknown.

Returns:

The sampled points.

Return type:

LabelTensor

Example:
>>> ellipsoid_domain = EllipsoidDomain({'x':[0, 1], 'y':[0, 1]})
>>> ellipsoid_domain.sample(n=5)
    LabelTensor([[0.7174, 0.5319],
                 [0.2713, 0.6518],
                 [0.1020, 0.4093],
                 [0.2102, 0.1353],
                 [0.4830, 0.1873]])
partial()[source]

Return the boundary of the domain as a new domain object.

Returns:

The boundary of the domain.

Return type:

EllipsoidDomain

property sample_surface

Whether only the surface of the ellipsoid is considered part of the domain.

Returns:

True if only the surface is considered part of the domain, False otherwise.

Return type:

bool