torchsky.map.likelihood¶
Experimental surface
These APIs are under active development. Names, defaults, and result objects may change between minor releases; pin a version if you depend on them in production.
Fixed Gaussian likelihood evidence and requested sampling uncertainty.
Guides: likelihoods, coadds
This reference is generated from the package source. Names are grouped by
the module that defines them; import every name from the public
namespace torchsky.map.likelihood unless the group text says otherwise.
Top-level namespace¶
Fixed Gaussian likelihood evidence and requested sampling uncertainty.
These objects reuse bound operators rather than rasterizing a new scene or assuming that measurements are images. Response and precision callbacks must be fixed, linear, and adjoint-consistent. Correlated observations or shared eliminated nuisances belong in one joint factor. They are not made independent by assigning different product names.
FunctionalSamplingUncertainty
dataclass
¶
FunctionalSamplingUncertainty(
sampling_variance: Tensor,
mean_response: Tensor,
solve_residual_norm: Tensor,
damping: float,
nuisance_treatments: tuple[NuisanceTreatment, ...],
_evidence_guard: Callable[[], None] | None = None,
)
Bases: _GuardedEvidence
Fixed-model sampling variance, mean transfer and solve diagnostics.
For ridge strength d, mean_response is H (H+d Id)^-1 g. It equals
g for an accurately solved unregularized estimable query. Otherwise its
difference from g describes possible bias and is not a confidence bound.
This result supplies no conformal or misspecification coverage guarantee.
Public numeric reads validate the factor evidence and query direction;
rebuild after changing either source.
_evidence_guard
class-attribute
instance-attribute
¶
_evidence_guard: Callable[[], None] | None = field(
default=None, repr=False, compare=False
)
_guarded_fields
class-attribute
instance-attribute
¶
_guarded_fields = frozenset(
{
"sampling_variance",
"mean_response",
"solve_residual_norm",
"damping",
}
)
GaussianLikelihoodFactor
dataclass
¶
GaussianLikelihoodFactor(
operator: BoundObservationOperator,
data: Tensor,
measurement_ids: tuple[str, ...],
calibration_id: str,
provenance_id: str,
nuisance_treatment: NuisanceTreatment = "conditional",
eliminated_nuisance_ids: tuple[str, ...] = (),
log_normalization: Tensor | None = None,
dependencies: EvidenceSnapshot | None = None,
)
One fixed Gaussian quadratic, with centered native data and lineage.
measurement_ids identify disjoint native sample groups, including the
constituent groups of a derived product. A mosaic and its inputs therefore
share identifiers. Callers own the truthful lineage and sampling partition.
eliminated_nuisance_ids identify unknowns profiled or integrated in this
factor; common unknowns must be eliminated jointly, not separately twice.
Supply data centered by the declared calibrated additive mean. Precision
callbacks own observed-support and real/complex noise conventions. This is
a quadratic likelihood kernel. For a conditional or calibrated Gaussian
density, supply its scalar log_normalization (e.g. half of
n log(2 pi) + logdet(C) in real coordinates). Otherwise absolute density
evaluation fails closed. Profiled nuisance objectives are not normalized
predictive densities. Rebuild after changing response, calibration, noise,
or data; tensors are not copied.
Data and normalization versions are tracked automatically. Supply an
EvidenceSnapshot in dependencies for callback matrices, module
parameters, noise, calibration and support, plus a revision getter for
mutable non-tensor state or replaced tensor bindings. Callback closures are
not inspected. Inference tensors require an explicit revision; callers own
revision changes for writes that bypass Torch mutation versions.
_operator_binding
class-attribute
instance-attribute
¶
_operator_binding: tuple[int, ...] = field(
init=False, repr=False, compare=False
)
_snapshot
class-attribute
instance-attribute
¶
_snapshot: EvidenceSnapshot = field(
init=False, repr=False, compare=False
)
eliminated_nuisance_ids
class-attribute
instance-attribute
¶
eliminated_nuisance_ids: tuple[str, ...] = ()
nuisance_treatment
class-attribute
instance-attribute
¶
nuisance_treatment: NuisanceTreatment = 'conditional'
validate_evidence ¶
validate_evidence() -> None
Reject changed data or declared physics before reusing this factor.
Mutable callback state needs dependencies; direct callback/target
replacement is also detected. Calibration/provenance IDs are lineage,
not mutation guards.
GaussianLikelihoodSystem
dataclass
¶
GaussianLikelihoodSystem(
factors: tuple[GaussianLikelihoodFactor, ...],
exposure_chunk_size: int = 1,
)
Independent fixed factors over a common scene, without a field solve.
Operators may emit native pixels, vectors, timelines or complex arrays. Nonlinear/Poisson likelihoods cannot use this quadratic compression. The system requires independent factors under their declared nuisance treatment; unrecorded correlation cannot be detected from metadata alone.
_operators
class-attribute
instance-attribute
¶
_operators: BoundObservationOperatorSet = field(
init=False, repr=False
)
functional_uncertainty ¶
functional_uncertainty(
functional: Tensor,
*,
iterations: int = 64,
damping: float = 0.0,
rtol: float = 1e-05,
atol: float = 0.0,
preconditioner: Callable[[Tensor], Tensor]
| Tensor
| None = None,
dependencies: EvidenceSnapshot | None = None,
) -> FunctionalSamplingUncertainty
Compute g^T K^-1 H K^-1 g, with K=H+d Id, using one solve.
A failed/inconsistent solve raises instead of reporting finite certainty
for an unmeasured query. Passing residual checks does not prove that all
sky modes are identifiable, or bound ill-conditioned forward error.
Direction versions are tracked automatically; an inference direction
requires a caller revision in dependencies. This optional snapshot
also covers other mutable query state not represented by the factors.
negative_log_likelihood ¶
negative_log_likelihood(state: Tensor) -> Tensor
Evaluate a normalized density only with declared Gaussian constants.
solve ¶
solve(
*,
iterations: int = 64,
damping: float = 0.0,
preconditioner: Callable[[Tensor], Tensor]
| Tensor
| None = None,
) -> LinearSolveResult
Use the shared matrix-free solver; this does not certify convergence.
validate_evidence ¶
validate_evidence() -> None
Validate all fixed factor dependencies without reading tensor contents.
GaussianNormalEquations
dataclass
¶
GaussianNormalEquations(
rhs: Tensor,
data_quadratic: Tensor,
information: Callable[[Tensor], Tensor],
measurement_ids: tuple[str, ...],
log_normalization: Tensor | None = None,
_evidence_guard: Callable[[], None] | None = None,
)
Bases: _GuardedEvidence
Full quadratic evidence x^T H x - 2 x^T b + c for fixed callbacks.
The full information action is retained. No diagonal approximation or
reconstructed image is presented as sufficient evidence. c excludes
determinant terms; optional log_normalization must be supplied by the
caller from the declared covariance and observed support.
Statistics returned by a likelihood system validate its declared sources on public reads and information calls. A previously retrieved tensor is an ordinary tensor; its later use cannot be intercepted.