observation.priors#

Hyperpriors and prior distributions for observation model parameters.

Classes

ObsParamsHyperPrior

Homogeneous hyperpriors for observation model parameters.

ObsParamsHyperPriorStructured

Structured hyperpriors with per-group, per-latent control.

ObsParamsPrior

Prior distributions over observation model parameters.


class ObsParamsHyperPrior(
*,
a_alpha: float = 1e-12,
b_alpha: float = 1e-12,
a_phi: float = 1e-12,
b_phi: float = 1e-12,
beta_d: float = 1e-12,
)[source]#

Homogeneous hyperpriors for observation model parameters.

Scalar values broadcast to all groups/latents. Typical for inference with uninformative priors.

Parameters:
a_alphafloat, default 1e-12

Shape parameter of the ARD prior (Gamma). Must be > 0.

b_alphafloat, default 1e-12

Rate parameter of the ARD prior (Gamma). Must be > 0.

a_phifloat, default 1e-12

Shape parameter of the observation precision prior (Gamma). Must be > 0.

b_phifloat, default 1e-12

Rate parameter of the observation precision prior (Gamma). Must be > 0.

beta_dfloat, default 1e-12

Precision of the observation mean prior (Gaussian). Must be > 0.

Examples

>>> priors = ObsParamsHyperPrior()  # Use defaults (uninformative)
>>> priors = ObsParamsHyperPrior(a_alpha=1e-6, b_alpha=1e-6)
class ObsParamsHyperPriorStructured(
*,
a_alpha: ndarray,
b_alpha: ndarray,
a_phi: float = 1.0,
b_phi: float = 1.0,
beta_d: float = 1.0,
)[source]#

Structured hyperpriors with per-group, per-latent control.

Enables sparsity constraints (np.inf in a_alpha forces zero loadings) and incorporation of prior knowledge.

Parameters:
a_alphandarray of float, shape (n_groups, x_dim)

Shape parameters for ARD priors. Use np.inf to force zero loadings (sparsity pattern).

b_alphandarray of float, shape (n_groups, x_dim)

Rate parameters for ARD priors. Typically ones or matched to a_alpha.

a_phifloat, default 1.0

Shape parameter of observation precision prior. Must be > 0.

b_phifloat, default 1.0

Rate parameter of observation precision prior. Must be > 0.

beta_dfloat, default 1.0

Precision of observation mean prior. Must be > 0.

Examples

>>> # 3 groups, 4 latents, with sparsity pattern
>>> sparsity = np.array([
...     [1, 1, np.inf, 1],      # Group 0: latents 0,1,3
...     [1, np.inf, 1, 1],      # Group 1: latents 0,2,3
...     [np.inf, 1, 1, 1],      # Group 2: latents 1,2,3
... ])
>>> priors = ObsParamsHyperPriorStructured(
...     a_alpha=100 * sparsity,
...     b_alpha=100 * np.ones((3, 4)),
... )
class ObsParamsPrior(
hyperprior: ObsParamsHyperPrior | ObsParamsHyperPriorStructured,
)[source]#

Prior distributions over observation model parameters.

Encapsulates p(C, d, phi, alpha) and handles correct sampling order (alpha must be sampled before C, since C|alpha ~ N(0, alpha^-1)).

Parameters:
hyperpriorObsParamsHyperPrior or ObsParamsHyperPriorStructured

Hyperprior parameters controlling the prior distributions.

sample(
y_dims: ndarray,
x_dim: int,
rng: Generator,
) ObsParamsRealization[source]#

Sample from joint prior p(alpha)p(C|alpha)p(d)p(phi).

Parameters:
y_dimsndarray of int, shape (n_groups,)

Dimensionalities of each observed group.

x_dimint

Number of latent dimensions.

rngnumpy.random.Generator

Random number generator.

Returns:
ObsParamsRealization

Sampled parameter values.