observation.priors#
Hyperpriors and prior distributions for observation model parameters.
Classes
Homogeneous hyperpriors for observation model parameters. |
|
Structured hyperpriors with per-group, per-latent control. |
|
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,
Homogeneous hyperpriors for observation model parameters.
Scalar values broadcast to all groups/latents. Typical for inference with uninformative priors.
- Parameters:
- a_alpha
float, default 1e-12 Shape parameter of the ARD prior (Gamma). Must be > 0.
- b_alpha
float, default 1e-12 Rate parameter of the ARD prior (Gamma). Must be > 0.
- a_phi
float, default 1e-12 Shape parameter of the observation precision prior (Gamma). Must be > 0.
- b_phi
float, default 1e-12 Rate parameter of the observation precision prior (Gamma). Must be > 0.
- beta_d
float, default 1e-12 Precision of the observation mean prior (Gaussian). Must be > 0.
- a_alpha
Examples
>>> priors = ObsParamsHyperPrior() # Use defaults (uninformative) >>> priors = ObsParamsHyperPrior(a_alpha=1e-6, b_alpha=1e-6)
- class ObsParamsHyperPriorStructured( )[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_alpha
ndarrayoffloat, shape (n_groups,x_dim) Shape parameters for ARD priors. Use np.inf to force zero loadings (sparsity pattern).
- b_alpha
ndarrayoffloat, shape (n_groups,x_dim) Rate parameters for ARD priors. Typically ones or matched to a_alpha.
- a_phi
float, default 1.0 Shape parameter of observation precision prior. Must be > 0.
- b_phi
float, default 1.0 Rate parameter of observation precision prior. Must be > 0.
- beta_d
float, default 1.0 Precision of observation mean prior. Must be > 0.
- a_alpha
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,
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:
- hyperprior
ObsParamsHyperPriororObsParamsHyperPriorStructured Hyperprior parameters controlling the prior distributions.
- hyperprior
- sample( ) ObsParamsRealization[source]#
Sample from joint prior p(alpha)p(C|alpha)p(d)p(phi).
- Parameters:
- y_dims
ndarrayofint, shape (n_groups,) Dimensionalities of each observed group.
- x_dim
int Number of latent dimensions.
- rng
numpy.random.Generator Random number generator.
- y_dims
- Returns:
ObsParamsRealizationSampled parameter values.