alphaFeedback

WorksMathematics

Bayesian Filters via the Stochastic Category

AI contributions
Not recorded for this paper
View details

Abstract

We extend the categorical treatment of Bayesian filters to models with feedback, whose transitions and observations may depend on the past observations. We work in the stochastic category, whose objects are measurable spaces and whose morphisms are Markov kernels, which we refer to as stochastic morphisms. We systematically parameterize stochastic morphisms by a measurable space, and develop the calculus of conditioning in a notation intuitively compatible with classical probability theory, requiring neither string diagrams nor densities. A stochastic morphism into a product space is regarded as a parameterized family of joint laws, and its conditional law is again a stochastic morphism, so that the rules of conditioning become equalities of stochastic morphisms. We define the Bayesian inverse with respect to a parameterized prior and prove Bayesian coherence. A model with feedback is then a model whose parameter space grows with the observations, and we derive the Bayesian filter, prediction and smoothing for such models, with standard Borel hidden states and countably generated observation spaces. The affine Gaussian stochastic morphisms parameterized by a measurable space form a family strictly larger than the Markov category Gauss\mathbf{Gauss}, closed under composition and Bayesian inversion, in which we obtain the Kalman filter and the Rauch-Tung-Striebel smoother with feedback.

Introduction

Stochastic morphisms, also known as Markov kernels, between measurable spaces were introduced by Lawvere [19] to express stochastic phenomena such as noise and uncertainty in categorical terms, and independently by Čencov [3, 4] from the viewpoint of statistical decision theory. The resulting category, which we call the stochastic category, was interpreted by Giry [14] as the Kleisli category of the probability monad, and its structure was axiomatized by Fritz [10] as Markov categories (see also [12]), in which marginalization, conditioning and independence are formulated through compositions and monoidal products of morphisms. In this framework, arguments are carried out with string diagrams, and classical algorithms such as the Bayesian filter [11, 25] and the smoother [11] can be derived uniformly.

In classical probability theory, Bayesian filters and their continuous time analogues have been studied extensively [1, 7, 16, 18, 23], and filters are naturally used with feedback, i.e. the transitions and observations of the model may depend on the observations made so far, for instance through a control input or through coefficients chosen based on the data [7 §4.2]. Such models are not hidden Markov models in the sense of [11], since the future is not conditionally independent of

Date: November 1, 2026.

2020 Mathematics Subject Classification. Primary: 60G35, Secondary: 60A05, 62F15, 18M05, 93E11, 28A50.

This work is supported in part by RIKEN AIP, as well as JST CREST Grant Number JPMJCR2112 (The Bayes-Duality Project FY2021–2026, led by Emtiyaz Khan). The second author is supported by the RIKEN Special Postdoctoral Researcher Program, FY2025–2027. the past given the current hidden state. They are instead characterized by their conditional laws given the whole past (Proposition 4.2). The purpose of this article is to extend the categorical interpretation of Bayesian filters to this setting, by systematically parameterizing stochastic morphisms, using notation intuitively compatible with classical probability. In categorical terms, fixed parameters are treated in [11] through the parametric Markov categories of [12 §2.2], and inputs appear in [25 Definition 3.1]. Parameterized stochastic morphisms also appear in [13] as transitional random variables. In this article, the parameter space grows with the observations. For simplicity, we work in the stochastic category, the motivating example of a Markov category.

We take the joint law as the primary object. A joint law is a stochastic morphism π:S→X×Y\pi: S \to X \times Y, that is, a family of probability measures π(s)\pi(s) on X×YX \times Y parameterized by a measurable space SS. We write

π(Y∣X):S×X→Y\pi(Y \mid X) : S \times X \to Y

for the conditional law of YY given XX for π\pi (see Definition 2.1), a family of regular conditional probabilities for the measures π(s)\pi(s), characterized by

π=(pr⁡X,π(Y∣X))∘(id⁡S,πX).\pi= (\operatorname{pr}_{X}, \pi(Y \mid X)) \circ(\operatorname{id}_{S}, \pi_{X}).

The notation makes explicit the joint law and the parameter space, and the factors XX and YY play the role traditionally played by random variables, conditioning on XX being conditioning on the projection pr⁡X\operatorname{pr}_{X} (see Remark 2.3). The essential point is that π(Y∣X)\pi(Y \mid X) is again a stochastic morphism, with parameter space S×XS \times X, so that further conditional laws can be taken and the rules of conditioning become equalities of stochastic morphisms. For example, the tower property (Theorem 2.7) for π:S→X×Y×Z\pi: S \to X \times Y \times Z reads

π(Y×Z∣X)(Z∣Y)=π(Z∣X×Y),\pi(Y \times Z \mid X)(Z \mid Y) = \pi(Z \mid X \times Y),

that is, conditioning on XX and then on YY is the same as conditioning on X×YX \times Y at once, corresponding to the identity p(z∣x,y)=p(y,z∣x)/p(y∣x)p(z \mid x,y) = p(y,z \mid x)/p(y \mid x) for densities. No reference measure or density is required, and measure theory is confined to the existence and uniqueness of the conditional law.

To see the calculus at work, consider the simplified case of a hidden Markov model without feedback when SS is a single point, with initial law μ\mu on X1X_{1}, transitions ak:Xk→Xk+1a_{k} : X_{k} \to X_{k+1} and observations hk:Xk→Ykh_{k} : X_{k} \to Y_{k} for integers k≥1k \ge1. Let bk:=(hk+1,id⁡Xk+1)∘ak:Xk→Yk+1×Xk+1b_{k} := (h_{k+1}, \operatorname{id}_{X_{k+1}}) \circ a_{k} : X_{k} \to Y_{k+1} \times X_{k+1}, which generates the next observation Yk+1Y_{k+1} and hidden state Xk+1X_{k+1} from XkX_{k}. The joint law πk\pi_{k} of the observations Y[k]:=Y1×⋯×YkY^{[k]} := Y_{1} \times\cdots\times Y_{k} and the hidden state XkX_{k} is the probability measure on Y[k]×XkY^{[k]} \times X_{k} given by push-forwards

π1:=(h1,id⁡X1)(μ),πk+1:=(id⁡Y[k]×bk)(πk)\pi_{1} := (h_{1}, \operatorname{id}_{X_{1}})(\mu), \qquad\pi_{k+1} := (\operatorname{id}_{Y^{[k]}} \times b_{k})(\pi_{k})

of measures, and the posterior is the conditional law

πk(Xk∣Y[k]):Y[k]→Xk\pi_{k}(X_{k} \mid Y^{[k]}) : Y^{[k]} \to X_{k}

giving a family of probability measures on XkX_{k} parameterized by the observations Y[k]Y^{[k]} up to time kk. The following two rules of the calculus give the Bayesian filter. Push-forward commutes with conditioning, so that

πk+1(Yk+1×Xk+1∣Y[k])=bk∘πk(Xk∣Y[k]),\pi_{k+1}(Y_{k+1} \times X_{k+1} \mid Y^{[k]}) = b_{k} \circ\pi_{k}(X_{k} \mid Y^{[k]}),

and the tower property then gives

πk+1(Xk+1∣Y[k+1])=(bk∘πk(Xk∣Y[k]))(Xk+1∣Yk+1).\pi_{k+1}(X_{k+1}\mid Y^{[k+1]})=(b_k\circ\pi_k(X_k\mid Y^{[k]}))(X_{k+1}\mid Y_{k+1}).

Since bk∘πk(Xk∣Y[k])=(hk+1,id⁡Xk+1)∘μk+1b_k\circ\pi_k(X_k\mid Y^{[k]})=(h_{k+1},\operatorname{id}_{X_{k+1}})\circ\mu_{k+1} for the predicted prior μk+1:=ak∘πk(Xk∣Y[k]):Y[k]→Xk+1\mu_{k+1}:=a_k\circ\pi_k(X_k\mid Y^{[k]}):Y^{[k]}\to X_{k+1}, the right hand side is the Bayesian inverse hk+1μk+1h_{k+1}^{\mu_{k+1}} of hk+1h_{k+1} with respect to μk+1\mu_{k+1}, a parameterized version of the Bayesian inverse of Cho and Jacobs [5]. This gives the Bayesian filter

πk+1(Xk+1∣Y[k+1])=hk+1μk+1,\pi_{k+1}(X_{k+1}\mid Y^{[k+1]})=h_{k+1}^{\mu_{k+1}},

which states that the posterior, a priori involving the whole model up to time k+1k+1, is the inverse of a single observation hk+1h_{k+1}, the past entering only through the predicted prior μk+1\mu_{k+1}.

The parameter space enables the iteration. The posterior πk(Xk∣Y[k])\pi_k(X_k\mid Y^{[k]}) is a stochastic morphism with parameter space Y[k]Y^{[k]}, and serves as the prior for the next observation. It also accommodates feedback. A transition or observation depending on the past observations is a stochastic morphism with parameter space Y[k]Y^{[k]}, so that a model with feedback is simply a model whose parameter space grows with the observations. Our main results, Theorems 4.6 and 4.7, establish the Bayesian filter for the joint law π\pi of the model with feedback, together with the corresponding recursions for prediction and smoothing, every step being a Bayesian inversion with the past observations entering as the parameter. In the case without feedback, the filter and the smoother are those of [11], obtained in Markov categories with conditionals, where the past observations are carried as an input of the conditional.

The hidden states are standard Borel, the observation spaces only countably generated, and the parameter space arbitrary. Since we work directly with conditional laws rather than conditional expectations, no integrability is assumed, and the results are equalities of stochastic morphisms holding for every value of the parameter s∈Ss\in S. In the affine Gaussian case with feedback, the filter and the smoother are classical for conditionally Gaussian sequences [18 Chapter 13], under integrability assumptions on the coefficients, and the filter is known to require only that the coefficients be almost surely finite [6]. In this article, the filter and the smoother follow from Theorems 4.6 and 4.7 for arbitrary measurable coefficients, in a family of affine Gaussian stochastic morphisms strictly larger than the Markov category Gauss of [10 §6]. Feedback is also natural in continuous time filtering, which will be treated in a subsequent article.

In classical terms, the conditional expectation of a bounded measurable function ff on YY given XX is the pull-back

Eπ[f∣X](s,x)=∫Yf(y) π(Y∣X)(s,x)(dy),(s,x)∈S×X,\mathbb{E}_{\pi}[f\mid X](s,x)=\int_Y f(y)\,\pi(Y\mid X)(s,x)(dy),\qquad(s,x)\in S\times X,

and the tower property of conditional expectations follows from that of conditional laws (Proposition B.6). In this sense, the calculus of conditional laws gives the calculus of conditional expectations.

The article is organized as follows. In §2 we first introduce conditional laws and augmentations. We then prove fundamental results such as the tower property, and formulate conditional independence. In §3 we define the Bayesian inverse and prove Bayesian coherence: updating observations successively gives the same posterior as updating them at once. In §4 we treat filtering, prediction and smoothing for hidden Markov models with feedback, and in §5 the Kalman filter and the Rauch–Tung–Striebel smoother. Appendix A gives a self-contained proof of the existence and uniqueness of the conditional law, which may be read independently, Appendix B relates our framework to classical expectations and conditional expectations, and Appendix C gives a dictionary between classical notation, the notation of Markov categories and our article.

Conditional Laws and Augmentations

Throughout this article, SS, XX, YY, ZZ, VV, WW denote measurable spaces. In this section, we define the conditional law of a parameterized joint law and prove fundamental properties such as the tower property, using augmentations of stochastic morphisms.

A measurable space XX is countably generated if its σ\sigma-algebra is generated by a countable family of measurable subsets, and standard Borel if it is isomorphic as a measurable space to a Borel subset of a Polish space with its Borel σ\sigma-algebra, or equivalently to a Borel subset of [0,1][0,1] (see [24 Theorem 3.3.13]). A standard Borel space is countably generated, and finite or countable products of standard Borel spaces are again standard Borel spaces.

A stochastic morphism p:X→Yp : X \to Y, also known as a Markov kernel, probabilistic mapping or transition probability from XX to YY, is a map sending any x∈Xx \in X to a probability measure p(x)p(x) on YY, such that for any measurable B⊂YB \subset Y, the map x↦p(x)(B)x \mapsto p(x)(B) is measurable in xx. Any measurable map f:X→Yf : X \to Y can be viewed as a stochastic morphism by mapping xx to the Dirac measure δf(x)\delta_{f(x)} on YY. We will call such a stochastic morphism a deterministic morphism. We denote by 1:={∗}1 := \{\ast\} the one-point measurable space. A probability measure μ\mu on XX defines a stochastic morphism μ:1→X\mu: 1 \to X mapping ∗\ast to μ\mu, and we will identify the two.

Given stochastic morphisms p:S→Xp : S \to X and q:X→Yq : X \to Y, we define the composition by

(q∘p)(s)(B):=∫Xq(x)(B)p(s)(dx)(q \circ p)(s)(B) := \int_X q(x)(B)p(s)(\mathrm{d}x)

for any s∈Ss \in S and measurable set B⊂YB \subset Y. Then q∘pq \circ p is again a stochastic morphism. Measurable spaces and stochastic morphisms form a category, the stochastic category, denoted Stoch in [10], with the deterministic morphisms induced by the identities as identities.

We denote by pr⁡X:X×Y→X\operatorname{pr}_{X} : X \times Y \to X and pr⁡Y:X×Y→Y\operatorname{pr}_{Y} : X \times Y \to Y the deterministic morphisms induced by the projections. More generally, we take the convention that on a product with several factors including XX and YY, we denote by pr⁡X×Y\operatorname{pr}_{X \times Y} and pr⁡Y×X\operatorname{pr}_{Y \times X} the projections to X×YX \times Y and to Y×XY \times X, the order of the indices indicating the order of the factors in the range, and similarly for projections to more than two factors. For stochastic morphisms p:S→Xp : S \to X and q:S→Yq : S \to Y, the product

(p,q):S→X×Y(p,q) : S \to X \times Y

References

  1. [1]A. Bain and D. Crisan, Fundamentals of stochastic filtering, Stochastic Modelling and Applied Probability, vol. 60, Springer, New York, 2009. MR2454694
  2. [2]D. Braithwaite, J. Hedges, and T. St. Clere Smithe, The compositional structure of Bayesian inference, 48th International Symposium on Mathematical Foundations of Computer Science (MFCS 2023), LIPIcs. Leibniz Int. Proc. Inform., vol. 272, Schloss Dagstuhl. Leibniz-Zent. Inform., Wadern, 2023, pp. Art. No. 24, 15, DOI 10.4230/LIPIcs.MFCS.2023.24.DOI
  3. [3]N. N. Chentsov, The categories of mathematical statistics, Dokl. Akad. Nauk SSSR 164 (1965), no. 3, 511–514 (Russian).
  4. [4]———, Statistical decision rules and optimal inference, Translations of Mathematical Monographs, vol. 53, American Mathematical Society, Providence, RI, 1982. Translation from the Russian edited by Lev J. Leifman. MR0645898
  5. [5]K. Kondo and B. Jacobs, Disintegration and Bayesian inversion via string diagrams, Math. Structures Comput. Sci. 29 (2019), no. 7, 938–971, DOI 10.1017/S0960129518000488. MR3987300
  6. [6]H.-F. Chen, P. R. Kumar, and J. H. van Schuppen, On Kalman filtering for conditionally Gaussian systems with random matrices, Systems Control Lett. 13 (1989), no. 5, 397–404, DOI 10.1016/0167-6911(89)90106-0.DOI
  7. [7]O. Cappé, E. Moulines, and T. Rydén, Inference in hidden Markov models, Springer Series in Statistics, Springer, New York, 2005. MR2159833DOI
  8. [8]J. Culbertson and K. Sturtz, A categorical foundation for Bayesian probability, Appl. Categ. Structures 22 (2014), no. 4, 647–662, DOI 10.1007/s10485-013-9324-9. MR3227607DOI
  9. [9]R. Degenne, Markov kernels in Mathlib’s probability library (2025), preprint, available at arXiv:2510.04070.arxiv.org/abs/2510.04070
  10. [10]T. Fritz, A synthetic approach to Markov kernels, conditional independence and theorems on sufficient statistics, Adv. Math. 370 (2020), 107239, DOI 10.1016/j.aim.2020.107239.DOI
  11. [11]T. Fritz, A. Klingler, D. McNeely, A. Shah Mohammad, and Y. Wang, Hidden Markov models and the Bayes filter in categorical probability, IEEE Trans. Inform. Theory 71 (2025), no. 9, 7052–7075, DOI 10.1109/tit.2025.3584695. MR4949428DOI
  12. [12]T. Fritz, T. Gonda, P. Perrone, and E. F. Rischel, Representable Markov categories and comparison of statistical experiments in categorical probability, Theoret. Comput. Sci. 961 (2023), Paper No. 113896, DOI 10.1016/j.tcs.2023.113896.DOI
  13. [13]P. Forré, Transitional conditional independence (2021), preprint, available at arXiv:2104.11547v5 [math. ST].arxiv.org/abs/2104.11547
  14. [14]M. Giry, A categorical approach to probability theory, in: Categorical Aspects of Topology and Analysis, Ottawa, Ont., 1980, Lecture Notes in Math., vol. 915, Springer, 1982, pp. 68–85.
  15. [15]E. T. Jaynes, Probability theory, Cambridge University Press, Cambridge, 2003. The logic of science; Edited and with a foreword by G. Larry Bretthorst. MR1992316
  16. [16]R. E. Kalman, A new approach to linear filtering and prediction problems, Trans. ASME Ser. D. J. Basic Engrg. 82 (1960), no. 1, 35–45, DOI 10.1115/1.3662552.DOI
  17. [17]O. Kallenberg, Random measures, theory and applications, Probability Theory and Stochastic Modeling, vol. 77, Springer, Cham, 2017. MR3642325DOI
  18. [18]R. S. Liptser and A. N. Shiryaev, Statistics of random processes. II. Applications, 2nd ed., Stochastic Modelling and Applied Probability, vol. 6, Springer-Verlag, Berlin, 2001.
  19. [19]F. W. Lawvere, The category of probabilistic mappings (1962), available at https://lawrerearchives.com/wp-content/uploads/2025/07/1962.probmap.pdf. Unpublished manuscript; posthumously published by the Lawvere Archives.
  20. [20]A. J. Parzygnat, Inverses, disintegrations, and Bayesian inversion in quantum Markov categories (2020), preprint, available at arXiv:2001.08375[quant-ph].arxiv.org/abs/2001.08375
  21. [21]H. E. Rauch, F. C. Tung, and C. T. Striebel, Maximum likelihood estimates of linear dynamic systems, AIAA J. 3 (1965), no. 8, 1445–1450, DOI 10.2514/3.3166.DOI
  22. [22]T. St. Clere Smithe, Bayesian updates compose optically (2020), preprint, available at arXiv:2006.01631[math.CT].
  23. [23]S. Särkkä and L. Svensson, Bayesian filtering and smoothing, 2nd ed., Institute of Mathematical Statistics Textbooks, vol. 17, Cambridge University Press, Cambridge, 2023.
  24. [24]S. M. Srivastava, A course on Borel sets, Graduate Texts in Mathematics, vol. 180, Springer-Verlag, New York, 1998. MR1619545
  25. [25]N. Virgo, Unifilar machines and the adjoint structure of Bayesian filtering, Proceedings of the Sixth International Conference on Applied Category Theory 2023, Electron. Proc. Theor. Comput. Sci. (EPTCS), vol. 397, 2023, pp. 299–317, DOI 10.4204/EPTCS.397.18.DOI

Paper details

vlnc:W_scuh9ngw
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Mathematics

Not recorded for this paper · View statement →

Looking for related papers…
Contents