Continuous Spaces

Continuous topological spaces and their properties.

spaces

Continuous measurable spaces for the hybrid architecture.

Continuous space objects serve as domains and codomains for continuous morphisms. They complement :mod:quivers.core.objects (FinSet etc.) used by discrete morphisms.

The space family is a sum type:

  • :class:Euclidean — :math:\mathbb{R}^d with optional bounds
  • :class:Simplex — probability simplex over d components
  • :class:PositiveReals — :math:(0, \infty)^d
  • :class:ProductSpace — cartesian product of continuous spaces

:func:UnitInterval is a convenience factory for [0, 1]^d.

ContinuousSpace

Bases: TaggedUnion

Continuous measurable space (Euclidean, Simplex, PositiveReals, Product).

Variants expose name: str and dim: int either as fields (the atomic variants) or as derived properties (:class:ProductSpace), plus a :meth:contains predicate over the support.

event_shape property

event_shape: tuple[int, ...]

Shape of a single sample.

contains

contains(x: Tensor) -> Tensor

Check whether points lie in the support.

Source code in src/quivers/continuous/spaces.py
43
44
45
def contains(self, x: torch.Tensor) -> torch.Tensor:
    """Check whether points lie in the support."""
    raise NotImplementedError(f"{type(self).__name__}.contains")

sample_uniform

sample_uniform(n: int) -> Tensor

Sample n points uniformly from the space.

Source code in src/quivers/continuous/spaces.py
47
48
49
50
51
def sample_uniform(self, n: int) -> torch.Tensor:
    """Sample n points uniformly from the space."""
    raise NotImplementedError(
        f"{type(self).__name__} does not support uniform sampling"
    )

Euclidean

Bases: ContinuousSpace

Euclidean space :math:\mathbb{R}^d, optionally bounded.

is_bounded property

is_bounded: bool

Whether the space has finite bounds on all sides.

Simplex

Bases: ContinuousSpace

The probability simplex :math:\{x \in \mathbb{R}^d : x_i \geq 0, \sum x_i = 1\}.

PositiveReals

Bases: ContinuousSpace

The positive reals :math:(0, \infty)^d.

ProductSpace

Bases: ContinuousSpace

Cartesian product of continuous spaces (and discrete objects).

Components may be a mix of :class:ContinuousSpace variants and :class:~quivers.core.objects.SetObject variants — programs whose domain or codomain combines discrete and continuous variables produce such a ProductSpace at compile time. Nested products are flattened on construction; :attr:name and :attr:dim are derived from :attr:components (for SetObject components, :attr:dim falls back to len(component.shape)).

UnitInterval

UnitInterval(name: str, dim: int = 1) -> Euclidean

Create a :math:[0, 1]^d bounded Euclidean space.

Source code in src/quivers/continuous/spaces.py
 99
100
101
def UnitInterval(name: str, dim: int = 1) -> Euclidean:
    """Create a :math:`[0, 1]^d` bounded Euclidean space."""
    return Euclidean(name=name, dim=dim, low=0.0, high=1.0)