Skip to content

Distributions

Common Gaussian-family classes are documented under Top-level API. This page documents Gaussian-family metadata objects that are available from gmm_divergence.distributions but are not exported at the root.

gmm_divergence.distributions

Public distribution API.

GaussianLike module-attribute

GaussianLike: TypeAlias = 'Gaussian | GaussianMixture'

CombinedGaussianMixture dataclass

CombinedGaussianMixture(mixture: GaussianMixture, mapping: MixtureMapping)

Wrapper dataclass for a combined GaussianMixture.

MixtureMapping dataclass

MixtureMapping(
    source_index: NDArray[intp], local_component_index: NDArray[intp]
)

local_component_index instance-attribute

local_component_index: NDArray[intp]

Component index within the original input mixture for each flattened output component.

source_index instance-attribute

source_index: NDArray[intp]

Index of the original input distribution for each flattened output component.

component_of

component_of(input_index: int, local_component_index: int) -> int

Return the flattened component of given source input and local component.

Returns:

  • int

    The flattened component index corresponding to the specified source input and local component.

Source code in src/gmm_divergence/distributions/_combine.py
def component_of(self, input_index: int, local_component_index: int) -> int:
    """Return the flattened component of given source input and local component.

    Returns
    -------
    int
        The flattened component index corresponding to the specified source
        input and local component.
    """
    mask = (self.source_index == input_index) & (
        self.local_component_index == local_component_index
    )
    if not np.any(mask):
        msg = (
            f"No component found for input_index={input_index},"
            f" local_component_index={local_component_index}"
        )
        raise ValueError(msg)
    return np.where(mask)[0][0]

source_of

source_of(component_index: int) -> tuple[int, int]

Return source input and local component index for flattened component.

Returns:

  • tuple[int, int]

    (input_index, local_component_index).

Source code in src/gmm_divergence/distributions/_combine.py
def source_of(self, component_index: int) -> tuple[int, int]:
    """Return source input and local component index for flattened component.

    Returns
    -------
    tuple[int, int]
        `(input_index, local_component_index)`.
    """
    return self.source_index[component_index], self.local_component_index[component_index]