predict_exposure
================

.. py:module:: smolgp.solvers.integrated.predict_exposure


Functions
---------

.. autoapisummary::

   smolgp.solvers.integrated.predict_exposure.predict_exposure


Module Contents
---------------

.. py:function:: predict_exposure(kernel, X, y, R, state_coords, conditioned_states, t_star: float, delta_star: float, instid_star: int)

   Predict the exposure-integrated posterior for a single out-of-sample test point
   :math:`(t_*, \delta_*, \mathrm{instid}_*)` with :math:`\delta_* > 0`.

   Returns the raw, unprojected augmented state (mean of shape ``(n,)`` and
   covariance of shape ``(n, n)``, where ``n = kernel.dimension``), matching
   the signature of :meth:`IntegratedStateSpaceSolver.predict` for
   instantaneous queries. That is, the returned result has the test point's
   exposure-integrated mean/variance staged at state index ``kernel.d + instid_star``.
   The ``kernel.observation_model`` is applied afterward in GaussianProcess.predict().

   The algorithm mirrors the instantaneous predict algorithm (Algorithm 1 in Rubenzahl
   & Hattori et al. 2026) but includes replaying the Kalman steps for any data points
   that overlap with the test exposure. A virtual extra instrument index is used to
   hold the test exposure's state, which is reset at the start of the exposure.

   1. Treat the test exposure as a new, *unobserved* measurement on a
      virtual extra instrument index ``num_insts`` (one past the real
      ones), by building ``kernel_ext`` with ``num_insts + 1``. Let the
      test exposure span the interval :math:`[a, b) = [t_* - \delta_*/2, t_* + \delta_*/2)`.
   2. **Phase A**: Transition from the filtered data point (or the prior,
      if retrodictive) immedietely before the test exposure start to the
      test state :math:`a`, then apply ``kernel_ext.reset_matrix`` to zero
      the virtual instrument there.
   3. **Phase B**: scan over every real state strictly inside :math:`[a, b)`
      and replay the Kalman filter predict/reset/update steps. This correctly
      updates the etst prediction with overlapping real observations.
   4. **Phase C**: one final predict-only transition from wherever Phase B
      left off to :math:`b`.
   5. **Phase D**: RTS-smooth the result against the nearest future real
      state on or after :math:`b`. This is skipped if the test point ends
      after all observed data.

   Because the test point is computed on a fully private index throughout,
   ``instid_star`` colliding with a real training instrument's id is harmless.
   ``instid_star`` is only used to choose where in the returned ``(n,)``/``(n, n)``
   arrays to stage the final probe mean/variance, so that the GP applies the
   observation model for the correct instrument.


