Skip to content

Commit 42674d9

Browse files
authored
Merge pull request #269 from probml/docs
Updating documentation
2 parents 3ea933e + f24b402 commit 42674d9

38 files changed

+2126
-1072
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To install the latest releast of dynamax from PyPi:
3939

4040
``` {.console}
4141
pip install dynamax # Install dynamax and core dependencies, or
42-
pip install dynamax[notebooks] # Install with dep's for demo notebooks
42+
pip install dynamax[notebooks] # Install with demo notebook dependencies
4343
```
4444

4545
To install the latest development branch:

docs/api.rst

Lines changed: 137 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,147 @@
1-
2-
API
3-
===
4-
51
State Space Model (Base class)
62
===============================
73

84
.. autoclass:: dynamax.ssm.SSM
95
:members:
106

7+
Parameters
8+
----------
9+
10+
Parameters and their associated properties are stored as :class:`jax.DeviceArray`
11+
and :class:`dynamax.parameters.ParameterProperties`, respectively. They are bundled together into a
12+
:class:`dynamax.parameters.ParameterSet` and a :class:`dynamax.parameters.PropertySet`, which are simply
13+
aliases for immutable datastructures (in our case, :class:`NamedTuple`).
14+
15+
.. autoclass:: dynamax.parameters.ParameterSet
16+
.. autoclass:: dynamax.parameters.PropertySet
17+
.. autoclass:: dynamax.parameters.ParameterProperties
18+
1119
Hidden Markov Model
1220
===================
1321

14-
High-level class
15-
----------------
22+
Abstract classes
23+
------------------
1624

1725
.. autoclass:: dynamax.hidden_markov_model.HMM
26+
:show-inheritance:
1827
:members:
1928

29+
.. autoclass:: dynamax.hidden_markov_model.HMMInitialState
30+
:members:
31+
32+
.. autoclass:: dynamax.hidden_markov_model.HMMTransitions
33+
:members:
34+
35+
.. autoclass:: dynamax.hidden_markov_model.HMMEmissions
36+
:members:
37+
38+
High-level models
39+
-----------------
40+
41+
The HMM implementations below cover common emission distributions and,
42+
if the emissions are exponential family distributions, the models implement
43+
closed form EM updates. For HMMs with emissions outside the non-exponential family,
44+
these models default to a generic M-step implemented in :class:`HMMEmissions`.
45+
46+
Unless otherwise specified, these models have standard initial distributions and
47+
transition distributions with conjugate, Bayesian priors on their parameters.
48+
49+
**Initial distribution:**
50+
51+
$$p(z_1 \mid \pi_1) = \mathrm{Cat}(z_1 \mid \pi_1)$$
52+
$$p(\pi_1) = \mathrm{Dir}(\pi_1 \mid \alpha 1_K)$$
53+
54+
where $\alpha$ is the prior concentration on the initial distribution $\pi_1$.
55+
56+
**Transition distribution:**
57+
58+
$$p(z_t \mid z_{t-1}, \theta) = \mathrm{Cat}(z_t \mid A_{z_{t-1}})$$
59+
$$p(A) = \prod_{k=1}^K \mathrm{Dir}(A_k \mid \beta 1_K)$$
60+
61+
where $\beta$ is the prior concentration on the rows of the transition matrix $A$.
62+
63+
64+
.. autoclass:: dynamax.hidden_markov_model.BernoulliHMM
65+
:show-inheritance:
66+
:members: initialize
67+
68+
.. autoclass:: dynamax.hidden_markov_model.CategoricalHMM
69+
:show-inheritance:
70+
:members: initialize
71+
72+
.. autoclass:: dynamax.hidden_markov_model.GaussianHMM
73+
:show-inheritance:
74+
:members: initialize
75+
76+
.. autoclass:: dynamax.hidden_markov_model.DiagonalGaussianHMM
77+
:show-inheritance:
78+
:members: initialize
79+
80+
.. autoclass:: dynamax.hidden_markov_model.SphericalGaussianHMM
81+
:show-inheritance:
82+
:members: initialize
83+
84+
.. autoclass:: dynamax.hidden_markov_model.SharedCovarianceGaussianHMM
85+
:show-inheritance:
86+
:members: initialize
87+
88+
.. autoclass:: dynamax.hidden_markov_model.LowRankGaussianHMM
89+
:show-inheritance:
90+
:members: initialize
91+
92+
.. autoclass:: dynamax.hidden_markov_model.MultinomialHMM
93+
:show-inheritance:
94+
:members: initialize
95+
96+
.. autoclass:: dynamax.hidden_markov_model.PoissonHMM
97+
:show-inheritance:
98+
:members: initialize
99+
100+
.. autoclass:: dynamax.hidden_markov_model.GaussianMixtureHMM
101+
:show-inheritance:
102+
:members: initialize
103+
104+
.. autoclass:: dynamax.hidden_markov_model.DiagonalGaussianMixtureHMM
105+
:show-inheritance:
106+
:members: initialize
107+
108+
.. autoclass:: dynamax.hidden_markov_model.LinearRegressionHMM
109+
:show-inheritance:
110+
:members: initialize
111+
112+
.. autoclass:: dynamax.hidden_markov_model.LogisticRegressionHMM
113+
:show-inheritance:
114+
:members: initialize
115+
116+
.. autoclass:: dynamax.hidden_markov_model.CategoricalRegressionHMM
117+
:show-inheritance:
118+
:members: initialize
119+
120+
.. autoclass:: dynamax.hidden_markov_model.LinearAutoregressiveHMM
121+
:show-inheritance:
122+
:members: initialize, sample, compute_inputs
123+
20124
Low-level inference
21125
-------------------
22126

127+
.. autoclass:: dynamax.hidden_markov_model.HMMPosterior
128+
.. autoclass:: dynamax.hidden_markov_model.HMMPosteriorFiltered
129+
23130
.. autofunction:: dynamax.hidden_markov_model.hmm_filter
24131
.. autofunction:: dynamax.hidden_markov_model.hmm_smoother
25132
.. autofunction:: dynamax.hidden_markov_model.hmm_two_filter_smoother
26133
.. autofunction:: dynamax.hidden_markov_model.hmm_fixed_lag_smoother
27134
.. autofunction:: dynamax.hidden_markov_model.hmm_posterior_mode
28135
.. autofunction:: dynamax.hidden_markov_model.hmm_posterior_sample
136+
.. autofunction:: dynamax.hidden_markov_model.parallel_hmm_filter
137+
.. autofunction:: dynamax.hidden_markov_model.parallel_hmm_smoother
138+
139+
Types
140+
-----
141+
142+
.. autoclass:: dynamax.hidden_markov_model.HMMParameterSet
143+
.. autoclass:: dynamax.hidden_markov_model.HMMPropertySet
144+
29145

30146
Linear Gaussian SSM
31147
====================
@@ -50,8 +166,9 @@ Types
50166
.. autoclass:: dynamax.linear_gaussian_ssm.ParamsLGSSMInitial
51167
.. autoclass:: dynamax.linear_gaussian_ssm.ParamsLGSSMDynamics
52168
.. autoclass:: dynamax.linear_gaussian_ssm.ParamsLGSSMEmissions
53-
.. autoclass:: dynamax.linear_gaussian_ssm.PosteriorLGSSMFiltered
54-
.. autoclass:: dynamax.linear_gaussian_ssm.PosteriorLGSSMSmoothed
169+
170+
.. autoclass:: dynamax.linear_gaussian_ssm.PosteriorGSSMFiltered
171+
.. autoclass:: dynamax.linear_gaussian_ssm.PosteriorGSSMSmoothed
55172

56173
Nonlinear Gaussian GSSM
57174
========================
@@ -74,6 +191,12 @@ Low-level inference
74191
.. autofunction:: dynamax.nonlinear_gaussian_ssm.unscented_kalman_filter
75192
.. autofunction:: dynamax.nonlinear_gaussian_ssm.unscented_kalman_smoother
76193

194+
Types
195+
-----
196+
197+
.. autoclass:: dynamax.nonlinear_gaussian_ssm.ParamsNLGSSM
198+
199+
77200
Generalized Gaussian GSSM
78201
==========================
79202

@@ -89,4 +212,9 @@ Low-level inference
89212
.. autofunction:: dynamax.generalized_gaussian_ssm.conditional_moments_gaussian_filter
90213
.. autofunction:: dynamax.generalized_gaussian_ssm.iterated_conditional_moments_gaussian_filter
91214
.. autofunction:: dynamax.generalized_gaussian_ssm.conditional_moments_gaussian_smoother
92-
.. autofunction:: dynamax.generalized_gaussian_ssm.iterated_conditional_moments_gaussian_smoother
215+
.. autofunction:: dynamax.generalized_gaussian_ssm.iterated_conditional_moments_gaussian_smoother
216+
217+
Types
218+
-----
219+
220+
.. autoclass:: dynamax.generalized_gaussian_ssm.ParamsGGSSM

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,5 @@
9999

100100
autosummary_generate = True
101101
autodoc_typehints = "description"
102-
add_module_names = False
102+
add_module_names = False
103+
autodoc_member_order = "bysource"

docs/index.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To install the latest releast of dynamax from PyPi:
3131
.. code-block:: console
3232
3333
pip install dynamax # Install dynamax and core dependencies, or
34-
pip install dynamax[notebooks] # Install with dep's for demo notebooks
34+
pip install dynamax[notebooks] # Install with demo notebook dependencies
3535
3636
3737
To install the latest development branch:
@@ -83,23 +83,23 @@ The corresponding joint distribution has the following form
8383

8484
.. math::
8585
86-
p(y_{1:T}, z_{1:T} | u_{1:T}) = p(z_1 | u_1) p(y_1 | z_1, u_1) \prod_{t=1}^T p(z_t | z_{t-1}, u_t) p(y_t | z_t, u_t)
86+
p(y_{1:T}, z_{1:T} \mid u_{1:T}) = p(z_1 \mid u_1) \prod_{t=2}^T p(z_t \mid z_{t-1}, u_t) \prod_{t=1}^T p(y_t \mid z_t, u_t)
8787
8888
89-
Here :math:`p(z_t | z_{t-1}, u_t)` is called the transition or dynamics model,
90-
and :math:`p(y_t | z_{t}, u_t)` is called the observation or emission model.
89+
Here :math:`p(z_t \mid z_{t-1}, u_t)` is called the transition or dynamics model,
90+
and :math:`p(y_t \mid z_{t}, u_t)` is called the observation or emission model.
9191
(In both cases, the inputs :math:`u_t` are optional;
9292
furthermore, the observation model may have auto-regressive dependencies,
93-
in which case we write :math:`p(y_t | z_{t}, u_t, y_{1:t-1})`.)
93+
in which case we write :math:`p(y_t \mid z_{t}, u_t, y_{1:t-1})`.)
9494

9595
We assume that we see the observations :math:`y_{1:T}`,
9696
and want to infer the hidden states, either
97-
using online filtering (i.e., computing :math:`p(z_t|y_{1:t})`)
98-
or offline smoothing (i.e., computing :math:`p(z_t|y_{1:T})`).
97+
using online filtering (i.e., computing :math:`p(z_t \mid y_{1:t})`)
98+
or offline smoothing (i.e., computing :math:`p(z_t \mid y_{1:T})`).
9999
We may also be interested in predicting future states,
100-
:math:`p(z_{t+h}|y_{1:t})`,
100+
:math:`p(z_{t+h} \mid y_{1:t})`,
101101
or future observations,
102-
:math:`p(y_{t+h}|y_{1:t})`,
102+
:math:`p(y_{t+h} \mid y_{1:t})`,
103103
where h is the forecast horizon.
104104
(Note that by using a hidden state to represent the past observations,
105105
the model can have "infinite" memory, unlike a standard auto-regressive model.)
@@ -204,7 +204,7 @@ API documentation
204204
==================
205205

206206
.. toctree::
207-
:maxdepth: 2
207+
:maxdepth: 3
208208
:caption: API Documentation
209209

210210
api

0 commit comments

Comments
 (0)