SharedMarginalLogLikelihood

class pmrf.objectives.shared.SharedMarginalLogLikelihood(datasets, latents)

Bases: AbstractTerm

Score datasets whose event-space discrepancies share latent functions.

The datasets are (MarginalLogLikelihood, Frequency) pairs, each with no local discrepancy. All kernel inputs use the first frequency’s unit. Latent rows are ordered by latent, then flattened kernel batch index, then frequency. A kernel row exists on the union of the fit frequency grids.

Parameters:
  • datasets (tuple[tuple[MarginalLogLikelihood, Frequency], ...]) – Per-dataset likelihood and fixed fit grid. Each likelihood must have Gaussian noise and no local or orthogonal discrepancy.

  • latents (tuple[SharedLatent, ...]) – Kernel and mixing pairs shared by all datasets.

  • Formulation** (**Mathematical)

  • varepsilon_l(x) ($$r_l(x) = sum_j M_{lj}(x)g_j(x) +)

  • qquad

  • Sigma_n.$$ (Sigma = Phi K_gPhi^top +)

  • \(K_g=LL^top\) (With)

  • is (the evaluated system)

  • latent-sized (\(C=I+L^topPhi^topSigma_n^{-1}Phi L\). Only)

  • formed. (matrices are)

References

ADR-0008 in the ParamRF repository.

__call__(model: PyTree) → Array

Return the joint marginal log-likelihood.

Parameters:

model (PyTree) – Model shared by the dataset predictors.

Returns:

Scalar log density, including conditional-transform Jacobians.

Return type:

jnp.ndarray

predict_discrepancy(model: PyTree, new_frequency: Frequency, *, dataset: int | None = None, prediction_event: Array | None = None) → AbstractDistribution

Predict event-space discrepancy for a fit dataset or a new prediction.

Pass dataset for a fitted dataset, or prediction_event for a new device on new_frequency. The returned joint Gaussian is flattened in event-block then frequency order.

Parameters:
  • model (PyTree) – Model shared by the fit dataset predictors.

  • new_frequency (Frequency) – Grid for the discrepancy posterior, in any unit.

  • dataset (int, optional) – Index of a dataset in the fit. Its predictor supplies the new event-space prediction.

  • prediction_event (jnp.ndarray, optional) – Event-space prediction for a new device that shares the latents. Supply this or dataset, but not both.

Returns:

Joint Gaussian over flattened event blocks and frequency, without measurement noise.

Return type:

dist.AbstractDistribution

predict_latents(model: PyTree, new_frequency: Frequency) → AbstractDistribution

Return one joint Gaussian over latent, row, then new frequency.

The returned vector excludes measurement noise. Rows follow latents order and each kernel’s flattened batch order.

Parameters:
  • model (PyTree) – Model shared by the dataset predictors.

  • new_frequency (Frequency) – Grid for the latent posterior, in any unit.

Returns:

Joint Gaussian, flattened by latent, row, then frequency.

Return type:

dist.AbstractDistribution

datasets: tuple[tuple[MarginalLogLikelihood, Frequency], ...]

Likelihoods and their fixed fit frequencies.

latents: tuple[SharedLatent, ...]

Latent functions shared across the datasets.

union_indices: tuple[Array, ...]

Indices into the union for each dataset’s fit points.

union_x: Array

Sorted union of fit frequencies in the first frequency’s unit.