support

Support Structures for Probability Distributions

This module defines support structures for probability distributions, including continuous intervals and discrete point sets.

Support defines the set of values where a probability distribution is defined (non-zero probability for discrete, non-zero density for continuous).

class pysatl_core.distributions.support.Support(*args, **kwargs)[source]

Bases: Protocol

Protocol for distribution support structures.

Support defines the set of values where a distribution is defined.

contains(**kwds)

Helper for @overload to raise when called.

__init__(*args, **kwargs)
class pysatl_core.distributions.support.ContinuousSupport(left=-inf, right=inf, left_closed=True, right_closed=True)[source]

Bases: Interval1D, Support

Support for continuous distributions represented as an interval.

This class inherits from Interval1D and implements the Support protocol for continuous distributions defined on an interval [left, right].

Parameters:
left: float
right: float
left_closed: bool
right_closed: bool
class pysatl_core.distributions.support.DiscreteSupport(*args, **kwargs)[source]

Bases: Support, Protocol

Protocol for discrete distribution supports.

Discrete supports consist of distinct points where the distribution has non-zero probability mass.

iter_points()[source]

Iterate through all points in the support.

Return type:

Iterator[floating[Any] | integer[Any] | int | float]

iter_leq(x)[source]

Iterate through points less than or equal to x.

Parameters:

x (Number) – Upper bound for points to iterate.

Return type:

Iterator[floating[Any] | integer[Any] | int | float]

prev(x)[source]

Find the largest point strictly less than x.

Parameters:

x (Number) – Reference point.

Returns:

Previous point if it exists, None otherwise.

Return type:

Number or None

class pysatl_core.distributions.support.ExplicitTableDiscreteSupport(points, assume_sorted=False)[source]

Bases: DiscreteSupport

Discrete support defined by an explicit list of points.

This implementation stores points in a sorted array for efficient membership testing and iteration.

Parameters:
  • points (Iterable[Number]) – Points in the support.

  • assume_sorted (bool, default False) – If True, assume points are already sorted and unique.

_points

Sorted unique points array.

Type:

numpy.ndarray

__init__(points, assume_sorted=False)[source]
Parameters:
Return type:

None

contains(x)[source]

Check if point(s) are in the support.

Parameters:

x (Number or NumericArray) – Point(s) to check.

Returns:

True for points in the support, False otherwise.

Return type:

bool or BoolArray

__contains__(x)[source]

Check if a point is in the support.

Return type:

bool

Parameters:

x (object)

iter_points()[source]

Iterate through all points in the support.

Return type:

Iterator[floating[Any] | integer[Any] | int | float]

iter_leq(x)[source]

Iterate through points less than or equal to x.

Parameters:

x (Number) – Upper bound.

Return type:

Iterator[floating[Any] | integer[Any] | int | float]

prev(x)[source]

Find the largest point strictly less than x.

Parameters:

x (Number) – Reference point.

Return type:

floating[Any] | integer[Any] | int | float | None

first()[source]

Get the smallest point in the support.

Return type:

floating[Any] | integer[Any] | int | float

next(current)[source]

Find the smallest point strictly greater than current.

Parameters:

current (Number) – Reference point.

Return type:

floating[Any] | integer[Any] | int | float | None

property points: ndarray[tuple[Any, ...], dtype[floating[Any] | integer[Any]]]

Get a copy of the points array.

__iter__()

Iterate through all points in the support.

Return type:

Iterator[floating[Any] | integer[Any] | int | float]

class pysatl_core.distributions.support.IntegerLatticeDiscreteSupport(residue, modulus, min_k=None, max_k=None)[source]

Bases: DiscreteSupport

Discrete support defined by an integer lattice: {residue + k * modulus}.

Parameters:
  • residue (int) – Base value for the lattice.

  • modulus (int) – Step size between lattice points (must be positive).

  • min_k (int, optional) – Minimum k value (inclusive).

  • max_k (int, optional) – Maximum k value (inclusive).

Raises:

ValueError – If modulus is not positive.

residue: int
modulus: int
min_k: int | None
max_k: int | None
contains(x)[source]

Check if point(s) are in the integer lattice support.

Points must be integers satisfying: x = residue (mod modulus) and be within bounds if min_k/max_k are specified.

Return type:

bool | ndarray[tuple[Any, ...], dtype[bool]]

Parameters:

x (floating[Any] | integer[Any] | int | float | ndarray[tuple[Any, ...], dtype[floating[Any] | integer[Any]]])

__contains__(x)[source]

Check if a point is in the integer lattice support.

Return type:

bool

Parameters:

x (object)

iter_points()[source]

Iterate through all points in the integer lattice support. :rtype: Iterator[int]

Note

If bounded from above and unbounded from below then iterates from upper bound in decreasing order

Raises:

RuntimeError – If both min_k and max_k are None (unbounded both ways).

Return type:

Iterator[int]

iter_leq(x)[source]

Iterate through points less than or equal to x.

Raises:

RuntimeError – If min_k is None (left-unbounded support).

Return type:

Iterator[int]

Parameters:

x (floating[Any] | integer[Any] | int | float)

prev(x)[source]

Find the largest point strictly less than x.

Return type:

int | None

Parameters:

x (floating[Any] | integer[Any] | int | float)

first()[source]

Get the smallest point in the support, or None if unbounded left.

Return type:

int | None

last()[source]

Get the largest point in the support, or None if unbounded right.

Return type:

int | None

__init__(residue, modulus, min_k=None, max_k=None)
Parameters:
  • residue (int)

  • modulus (int)

  • min_k (int | None)

  • max_k (int | None)

Return type:

None

next(current)[source]

Find the smallest point strictly greater than current.

Return type:

int | None

Parameters:

current (int)

property is_left_bounded: bool

Check if the support is bounded on the left.

property is_right_bounded: bool

Check if the support is bounded on the right.

__iter__()

Iterate through all points in the integer lattice support. :rtype: Iterator[int]

Note

If bounded from above and unbounded from below then iterates from upper bound in decreasing order

Raises:

RuntimeError – If both min_k and max_k are None (unbounded both ways).

Return type:

Iterator[int]