Skip to content

Box

lerax.space.Box

Bases: AbstractSpace[Float[Array, ' ...'], None]

A space of continuous values.

Values in the Box space can be unbounded (i.e., infinite) on either the lower or upper end. Sampling from an unbounded dimension uses a normal distribution. Sampling from a dimension that is only bounded on one end uses an exponential distribution shifted to the bound. Sampling a bounded dimension uses a uniform distribution.

Attributes:

Name Type Description
low Float[Array, '#n']

The lower bounds of the space.

high Float[Array, '#n']

The upper bounds of the space.

shape tuple[int, ...]

The shape of the space.

Parameters:

Name Type Description Default
low Float[ArrayLike, '#n']

The lower bounds of the space.

required
high Float[ArrayLike, '#n']

The upper bounds of the space.

required
shape tuple[int, ...] | None

The shape of the space. If None, the shape is inferred from low and high.

None

_shape instance-attribute

_shape: tuple[int, ...] = shape

low instance-attribute

low: Float[Array, '#n'] = jnp.broadcast_to(low, shape)

high instance-attribute

high: Float[Array, '#n'] = jnp.broadcast_to(high, shape)

shape property

shape: tuple[int, ...]

flat_size property

flat_size: int

__contains__

__contains__(x: Any) -> bool

__init__

__init__(
    low: Float[ArrayLike, "#n"],
    high: Float[ArrayLike, "#n"],
    shape: tuple[int, ...] | None = None,
)

canonical

canonical() -> Float[Array, ' ...']

sample

sample(
    *, key: Key, mask: None = None
) -> Float[Array, " ..."]

contains

contains(x: Any) -> Bool[Array, '']

__eq__

__eq__(other: object) -> bool

__repr__

__repr__() -> str

__hash__

__hash__() -> int

flatten_sample

flatten_sample(
    sample: Float[Array, " ..."],
) -> Float[Array, " n"]