Browse Source

move ssm-book to probml repo

Kevin P Murphy 3 years ago
parent
commit
bf685c070e
100 changed files with 2312 additions and 0 deletions
  1. BIN
      _build/.doctrees/README.doctree
  2. BIN
      _build/.doctrees/bib.doctree
  3. BIN
      _build/.doctrees/chapters/adf/adf_index.doctree
  4. BIN
      _build/.doctrees/chapters/blank.doctree
  5. BIN
      _build/.doctrees/chapters/bnp/bnp_index.doctree
  6. BIN
      _build/.doctrees/chapters/changepoint/changepoint_index.doctree
  7. BIN
      _build/.doctrees/chapters/control/control_index.doctree
  8. BIN
      _build/.doctrees/chapters/ensemble/ensemble_index.doctree
  9. BIN
      _build/.doctrees/chapters/extended/extended_filter.doctree
  10. BIN
      _build/.doctrees/chapters/extended/extended_index.doctree
  11. BIN
      _build/.doctrees/chapters/extended/extended_parallel.doctree
  12. BIN
      _build/.doctrees/chapters/extended/extended_smoother.doctree
  13. BIN
      _build/.doctrees/chapters/gp/gp_index.doctree
  14. BIN
      _build/.doctrees/chapters/hmm/hmm_filter.doctree
  15. BIN
      _build/.doctrees/chapters/hmm/hmm_index.doctree
  16. BIN
      _build/.doctrees/chapters/hmm/hmm_parallel.doctree
  17. BIN
      _build/.doctrees/chapters/hmm/hmm_sampling.doctree
  18. BIN
      _build/.doctrees/chapters/hmm/hmm_smoother.doctree
  19. BIN
      _build/.doctrees/chapters/hmm/hmm_viterbi.doctree
  20. BIN
      _build/.doctrees/chapters/learning/em.doctree
  21. BIN
      _build/.doctrees/chapters/learning/learning_index.doctree
  22. BIN
      _build/.doctrees/chapters/learning/mcmc.doctree
  23. BIN
      _build/.doctrees/chapters/learning/sgd.doctree
  24. BIN
      _build/.doctrees/chapters/learning/vb.doctree
  25. BIN
      _build/.doctrees/chapters/lgssm/kalman_filter.doctree
  26. BIN
      _build/.doctrees/chapters/lgssm/kalman_parallel.doctree
  27. BIN
      _build/.doctrees/chapters/lgssm/kalman_sampling.doctree
  28. BIN
      _build/.doctrees/chapters/lgssm/kalman_smoother.doctree
  29. BIN
      _build/.doctrees/chapters/lgssm/lgssm_index.doctree
  30. BIN
      _build/.doctrees/chapters/ode/ode_index.doctree
  31. BIN
      _build/.doctrees/chapters/pf/pf_index.doctree
  32. BIN
      _build/.doctrees/chapters/postlin/postlin_index.doctree
  33. BIN
      _build/.doctrees/chapters/quadrature/quadrature_index.doctree
  34. BIN
      _build/.doctrees/chapters/scratch.doctree
  35. BIN
      _build/.doctrees/chapters/smc/smc_index.doctree
  36. BIN
      _build/.doctrees/chapters/ssm/deep.doctree
  37. BIN
      _build/.doctrees/chapters/ssm/hmm.doctree
  38. BIN
      _build/.doctrees/chapters/ssm/hsmm.doctree
  39. BIN
      _build/.doctrees/chapters/ssm/lgssm.doctree
  40. BIN
      _build/.doctrees/chapters/ssm/nongauss.doctree
  41. BIN
      _build/.doctrees/chapters/ssm/nonlin.doctree
  42. BIN
      _build/.doctrees/chapters/ssm/rnn.doctree
  43. BIN
      _build/.doctrees/chapters/ssm/ssm_index.doctree
  44. BIN
      _build/.doctrees/chapters/ssm/switching.doctree
  45. BIN
      _build/.doctrees/chapters/timeseries/timeseries_index.doctree
  46. BIN
      _build/.doctrees/chapters/tracking/tracking_index.doctree
  47. BIN
      _build/.doctrees/chapters/unscented/unscented_filter.doctree
  48. BIN
      _build/.doctrees/chapters/unscented/unscented_index.doctree
  49. BIN
      _build/.doctrees/chapters/unscented/unscented_smoother.doctree
  50. BIN
      _build/.doctrees/chapters/vi/vi_index.doctree
  51. BIN
      _build/.doctrees/environment.pickle
  52. 1 0
      _build/.doctrees/glue_cache.json
  53. BIN
      _build/.doctrees/root.doctree
  54. 4 0
      _build/html/.buildinfo
  55. 529 0
      _build/html/README.html
  56. BIN
      _build/html/_images/casino.png
  57. BIN
      _build/html/_images/cat_dog.jpg
  58. BIN
      _build/html/_images/scratch_2_0.png
  59. 1 0
      _build/html/_panels_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css
  60. 7 0
      _build/html/_panels_static/panels-variables.06eb56fa6e07937060861dad626602ad.css
  61. 3 0
      _build/html/_sources/README.md
  62. 5 0
      _build/html/_sources/bib.md
  63. 13 0
      _build/html/_sources/chapters/adf/adf_index.md
  64. 39 0
      _build/html/_sources/chapters/blank.ipynb
  65. 9 0
      _build/html/_sources/chapters/bnp/bnp_index.md
  66. 14 0
      _build/html/_sources/chapters/changepoint/changepoint_index.md
  67. 19 0
      _build/html/_sources/chapters/control/control_index.md
  68. 10 0
      _build/html/_sources/chapters/ensemble/ensemble_index.md
  69. 32 0
      _build/html/_sources/chapters/extended/extended_filter.ipynb
  70. 7 0
      _build/html/_sources/chapters/extended/extended_index.md
  71. 34 0
      _build/html/_sources/chapters/extended/extended_parallel.ipynb
  72. 32 0
      _build/html/_sources/chapters/extended/extended_smoother.ipynb
  73. 13 0
      _build/html/_sources/chapters/gp/gp_index.md
  74. 32 0
      _build/html/_sources/chapters/hmm/hmm_filter.ipynb
  75. 10 0
      _build/html/_sources/chapters/hmm/hmm_index.md
  76. 36 0
      _build/html/_sources/chapters/hmm/hmm_parallel.ipynb
  77. 32 0
      _build/html/_sources/chapters/hmm/hmm_sampling.ipynb
  78. 51 0
      _build/html/_sources/chapters/hmm/hmm_smoother.ipynb
  79. 32 0
      _build/html/_sources/chapters/hmm/hmm_viterbi.ipynb
  80. 35 0
      _build/html/_sources/chapters/learning/em.ipynb
  81. 7 0
      _build/html/_sources/chapters/learning/learning_index.md
  82. 34 0
      _build/html/_sources/chapters/learning/mcmc.ipynb
  83. 34 0
      _build/html/_sources/chapters/learning/sgd.ipynb
  84. 35 0
      _build/html/_sources/chapters/learning/vb.ipynb
  85. 32 0
      _build/html/_sources/chapters/lgssm/kalman_filter.ipynb
  86. 37 0
      _build/html/_sources/chapters/lgssm/kalman_parallel.ipynb
  87. 32 0
      _build/html/_sources/chapters/lgssm/kalman_sampling.ipynb
  88. 32 0
      _build/html/_sources/chapters/lgssm/kalman_smoother.ipynb
  89. 7 0
      _build/html/_sources/chapters/lgssm/lgssm_index.md
  90. 12 0
      _build/html/_sources/chapters/ode/ode_index.md
  91. 10 0
      _build/html/_sources/chapters/pf/pf_index.md
  92. 12 0
      _build/html/_sources/chapters/postlin/postlin_index.md
  93. 12 0
      _build/html/_sources/chapters/quadrature/quadrature_index.md
  94. 204 0
      _build/html/_sources/chapters/scratch.ipynb
  95. 116 0
      _build/html/_sources/chapters/scratch.md
  96. 14 0
      _build/html/_sources/chapters/smc/smc_index.md
  97. 37 0
      _build/html/_sources/chapters/ssm/deep.ipynb
  98. 612 0
      _build/html/_sources/chapters/ssm/hmm.ipynb
  99. 33 0
      _build/html/_sources/chapters/ssm/hsmm.ipynb
  100. 0 0
      _build/html/_sources/chapters/ssm/lgssm.ipynb

BIN
_build/.doctrees/README.doctree


BIN
_build/.doctrees/bib.doctree


BIN
_build/.doctrees/chapters/adf/adf_index.doctree


BIN
_build/.doctrees/chapters/blank.doctree


BIN
_build/.doctrees/chapters/bnp/bnp_index.doctree


BIN
_build/.doctrees/chapters/changepoint/changepoint_index.doctree


BIN
_build/.doctrees/chapters/control/control_index.doctree


BIN
_build/.doctrees/chapters/ensemble/ensemble_index.doctree


BIN
_build/.doctrees/chapters/extended/extended_filter.doctree


BIN
_build/.doctrees/chapters/extended/extended_index.doctree


BIN
_build/.doctrees/chapters/extended/extended_parallel.doctree


BIN
_build/.doctrees/chapters/extended/extended_smoother.doctree


BIN
_build/.doctrees/chapters/gp/gp_index.doctree


BIN
_build/.doctrees/chapters/hmm/hmm_filter.doctree


BIN
_build/.doctrees/chapters/hmm/hmm_index.doctree


BIN
_build/.doctrees/chapters/hmm/hmm_parallel.doctree


BIN
_build/.doctrees/chapters/hmm/hmm_sampling.doctree


BIN
_build/.doctrees/chapters/hmm/hmm_smoother.doctree


BIN
_build/.doctrees/chapters/hmm/hmm_viterbi.doctree


BIN
_build/.doctrees/chapters/learning/em.doctree


BIN
_build/.doctrees/chapters/learning/learning_index.doctree


BIN
_build/.doctrees/chapters/learning/mcmc.doctree


BIN
_build/.doctrees/chapters/learning/sgd.doctree


BIN
_build/.doctrees/chapters/learning/vb.doctree


BIN
_build/.doctrees/chapters/lgssm/kalman_filter.doctree


BIN
_build/.doctrees/chapters/lgssm/kalman_parallel.doctree


BIN
_build/.doctrees/chapters/lgssm/kalman_sampling.doctree


BIN
_build/.doctrees/chapters/lgssm/kalman_smoother.doctree


BIN
_build/.doctrees/chapters/lgssm/lgssm_index.doctree


BIN
_build/.doctrees/chapters/ode/ode_index.doctree


BIN
_build/.doctrees/chapters/pf/pf_index.doctree


BIN
_build/.doctrees/chapters/postlin/postlin_index.doctree


BIN
_build/.doctrees/chapters/quadrature/quadrature_index.doctree


BIN
_build/.doctrees/chapters/scratch.doctree


BIN
_build/.doctrees/chapters/smc/smc_index.doctree


BIN
_build/.doctrees/chapters/ssm/deep.doctree


BIN
_build/.doctrees/chapters/ssm/hmm.doctree


BIN
_build/.doctrees/chapters/ssm/hsmm.doctree


BIN
_build/.doctrees/chapters/ssm/lgssm.doctree


BIN
_build/.doctrees/chapters/ssm/nongauss.doctree


BIN
_build/.doctrees/chapters/ssm/nonlin.doctree


BIN
_build/.doctrees/chapters/ssm/rnn.doctree


BIN
_build/.doctrees/chapters/ssm/ssm_index.doctree


BIN
_build/.doctrees/chapters/ssm/switching.doctree


BIN
_build/.doctrees/chapters/timeseries/timeseries_index.doctree


BIN
_build/.doctrees/chapters/tracking/tracking_index.doctree


BIN
_build/.doctrees/chapters/unscented/unscented_filter.doctree


BIN
_build/.doctrees/chapters/unscented/unscented_index.doctree


BIN
_build/.doctrees/chapters/unscented/unscented_smoother.doctree


BIN
_build/.doctrees/chapters/vi/vi_index.doctree


BIN
_build/.doctrees/environment.pickle


+ 1 - 0
_build/.doctrees/glue_cache.json

@@ -0,0 +1 @@
+{}

BIN
_build/.doctrees/root.doctree


+ 4 - 0
_build/html/.buildinfo

@@ -0,0 +1,4 @@
+# Sphinx build info version 1
+# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
+config: c5a2310bf13978b00c67ecd28add61e0
+tags: 645f666f9bcd5a90fca523b33c5a78b7

+ 529 - 0
_build/html/README.html

@@ -0,0 +1,529 @@
+
+<!DOCTYPE html>
+
+<html>
+  <head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>ssm-book &#8212; State Space Models: A Modern Approach</title>
+    
+  <link href="_static/css/theme.css" rel="stylesheet">
+  <link href="_static/css/index.ff1ffe594081f20da1ef19478df9384b.css" rel="stylesheet">
+
+    
+  <link rel="stylesheet"
+    href="_static/vendor/fontawesome/5.13.0/css/all.min.css">
+  <link rel="preload" as="font" type="font/woff2" crossorigin
+    href="_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
+  <link rel="preload" as="font" type="font/woff2" crossorigin
+    href="_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
+
+    
+      
+
+    
+    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
+    <link rel="stylesheet" type="text/css" href="_static/sphinx-book-theme.css?digest=c3fdc42140077d1ad13ad2f1588a4309" />
+    <link rel="stylesheet" type="text/css" href="_static/togglebutton.css" />
+    <link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
+    <link rel="stylesheet" type="text/css" href="_static/mystnb.css" />
+    <link rel="stylesheet" type="text/css" href="_static/sphinx-thebe.css" />
+    <link rel="stylesheet" type="text/css" href="_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
+    <link rel="stylesheet" type="text/css" href="_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />
+    
+  <link rel="preload" as="script" href="_static/js/index.be7d3bbb2ef33a8344ce.js">
+
+    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
+    <script src="_static/jquery.js"></script>
+    <script src="_static/underscore.js"></script>
+    <script src="_static/doctools.js"></script>
+    <script src="_static/clipboard.min.js"></script>
+    <script src="_static/copybutton.js"></script>
+    <script>let toggleHintShow = 'Click to show';</script>
+    <script>let toggleHintHide = 'Click to hide';</script>
+    <script>let toggleOpenOnPrint = 'true';</script>
+    <script src="_static/togglebutton.js"></script>
+    <script>var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
+    <script src="_static/sphinx-book-theme.d59cb220de22ca1c485ebbdc042f0030.js"></script>
+    <script>const THEBE_JS_URL = "https://unpkg.com/thebe@0.8.2/lib/index.js"
+const thebe_selector = ".thebe,.cell"
+const thebe_selector_input = "pre"
+const thebe_selector_output = ".output, .cell_output"
+</script>
+    <script async="async" src="_static/sphinx-thebe.js"></script>
+    <link rel="index" title="Index" href="genindex.html" />
+    <link rel="search" title="Search" href="search.html" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
+    <meta name="docsearch:language" content="None">
+    
+
+    <!-- Google Analytics -->
+    
+  </head>
+  <body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
+    
+    <div class="container-fluid" id="banner"></div>
+
+    
+
+    <div class="container-xl">
+      <div class="row">
+          
+<div class="col-12 col-md-3 bd-sidebar site-navigation show" id="site-navigation">
+    
+        <div class="navbar-brand-box">
+    <a class="navbar-brand text-wrap" href="index.html">
+      
+      
+      
+      <h1 class="site-logo" id="site-title">State Space Models: A Modern Approach</h1>
+      
+    </a>
+</div><form class="bd-search d-flex align-items-center" action="search.html" method="get">
+  <i class="icon fas fa-search"></i>
+  <input type="search" class="form-control" name="q" id="search-input" placeholder="Search this book..." aria-label="Search this book..." autocomplete="off" >
+</form><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
+    <div class="bd-toc-item active">
+        <ul class="nav bd-sidenav">
+ <li class="toctree-l1">
+  <a class="reference internal" href="root.html">
+   State Space Models: A Modern Approach
+  </a>
+ </li>
+</ul>
+<ul class="nav bd-sidenav">
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/scratch.html">
+   Scratchpad
+  </a>
+ </li>
+ <li class="toctree-l1 has-children">
+  <a class="reference internal" href="chapters/ssm/ssm_index.html">
+   Introduction
+  </a>
+  <input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
+  <label for="toctree-checkbox-1">
+   <i class="fas fa-chevron-down">
+   </i>
+  </label>
+  <ul>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/ssm/hmm.html">
+     Hidden Markov Models
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/ssm/hsmm.html">
+     Hidden Semi-Markov Models
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/ssm/lgssm.html">
+     Linear Gaussian SSMs
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/ssm/nonlin.html">
+     Non-Linear Gaussian SSMs
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/ssm/nongauss.html">
+     Non-Gaussian SSMs
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/ssm/switching.html">
+     Switching SSMs
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/ssm/deep.html">
+     Deep SSMs
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/ssm/rnn.html">
+     Recurrent Neural Networks
+    </a>
+   </li>
+  </ul>
+ </li>
+ <li class="toctree-l1 has-children">
+  <a class="reference internal" href="chapters/hmm/hmm_index.html">
+   Inference in discrete SSMs
+  </a>
+  <input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" type="checkbox"/>
+  <label for="toctree-checkbox-2">
+   <i class="fas fa-chevron-down">
+   </i>
+  </label>
+  <ul>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/hmm/hmm_filter.html">
+     HMM filtering (forwards algorithm)
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/hmm/hmm_smoother.html">
+     HMM smoothing (forwards-backwards algorithm)
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/hmm/hmm_viterbi.html">
+     Viterbi algorithm
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/hmm/hmm_parallel.html">
+     Parallel HMM  smoothing
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/hmm/hmm_sampling.html">
+     Forwards-filtering backwards-sampling algorithm
+    </a>
+   </li>
+  </ul>
+ </li>
+ <li class="toctree-l1 has-children">
+  <a class="reference internal" href="chapters/lgssm/lgssm_index.html">
+   Inference in linear-Gaussian SSMs
+  </a>
+  <input class="toctree-checkbox" id="toctree-checkbox-3" name="toctree-checkbox-3" type="checkbox"/>
+  <label for="toctree-checkbox-3">
+   <i class="fas fa-chevron-down">
+   </i>
+  </label>
+  <ul>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/lgssm/kalman_filter.html">
+     Kalman filtering
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/lgssm/kalman_smoother.html">
+     Kalman (RTS) smoother
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/lgssm/kalman_parallel.html">
+     Parallel Kalman Smoother
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/lgssm/kalman_sampling.html">
+     Forwards-filtering backwards sampling
+    </a>
+   </li>
+  </ul>
+ </li>
+ <li class="toctree-l1 has-children">
+  <a class="reference internal" href="chapters/extended/extended_index.html">
+   Extended (linearized) methods
+  </a>
+  <input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/>
+  <label for="toctree-checkbox-4">
+   <i class="fas fa-chevron-down">
+   </i>
+  </label>
+  <ul>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/extended/extended_filter.html">
+     Extended Kalman filtering
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/extended/extended_smoother.html">
+     Extended Kalman smoother
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/extended/extended_parallel.html">
+     Parallel extended Kalman smoothing
+    </a>
+   </li>
+  </ul>
+ </li>
+ <li class="toctree-l1 has-children">
+  <a class="reference internal" href="chapters/unscented/unscented_index.html">
+   Unscented methods
+  </a>
+  <input class="toctree-checkbox" id="toctree-checkbox-5" name="toctree-checkbox-5" type="checkbox"/>
+  <label for="toctree-checkbox-5">
+   <i class="fas fa-chevron-down">
+   </i>
+  </label>
+  <ul>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/unscented/unscented_filter.html">
+     Unscented filtering
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/unscented/unscented_smoother.html">
+     Unscented smoothing
+    </a>
+   </li>
+  </ul>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/quadrature/quadrature_index.html">
+   Quadrature and cubature methods
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/postlin/postlin_index.html">
+   Posterior linearization
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/adf/adf_index.html">
+   Assumed Density Filtering
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/vi/vi_index.html">
+   Variational inference
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/pf/pf_index.html">
+   Particle filtering
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/smc/smc_index.html">
+   Sequential Monte Carlo
+  </a>
+ </li>
+ <li class="toctree-l1 has-children">
+  <a class="reference internal" href="chapters/learning/learning_index.html">
+   Offline parameter estimation (learning)
+  </a>
+  <input class="toctree-checkbox" id="toctree-checkbox-6" name="toctree-checkbox-6" type="checkbox"/>
+  <label for="toctree-checkbox-6">
+   <i class="fas fa-chevron-down">
+   </i>
+  </label>
+  <ul>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/learning/em.html">
+     Expectation Maximization (EM)
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/learning/sgd.html">
+     Stochastic Gradient Descent (SGD)
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/learning/vb.html">
+     Variational Bayes (VB)
+    </a>
+   </li>
+   <li class="toctree-l2">
+    <a class="reference internal" href="chapters/learning/mcmc.html">
+     Markov Chain Monte Carlo (MCMC)
+    </a>
+   </li>
+  </ul>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/tracking/tracking_index.html">
+   Multi-target tracking
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/ensemble/ensemble_index.html">
+   Data assimilation using Ensemble Kalman filter
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/bnp/bnp_index.html">
+   Bayesian non-parametric SSMs
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/changepoint/changepoint_index.html">
+   Changepoint detection
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/timeseries/timeseries_index.html">
+   Timeseries forecasting
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/gp/gp_index.html">
+   Markovian Gaussian processes
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/ode/ode_index.html">
+   Differential equations and SSMs
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="chapters/control/control_index.html">
+   Optimal control
+  </a>
+ </li>
+ <li class="toctree-l1">
+  <a class="reference internal" href="bib.html">
+   Bibliography
+  </a>
+ </li>
+</ul>
+
+    </div>
+</nav> <!-- To handle the deprecated key -->
+
+<div class="navbar_extra_footer">
+  Powered by <a href="https://jupyterbook.org">Jupyter Book</a>
+</div>
+
+</div>
+
+
+          
+
+
+          
+<main class="col py-md-3 pl-md-4 bd-content overflow-auto" role="main">
+    
+    <div class="topbar container-xl fixed-top">
+    <div class="topbar-contents row">
+        <div class="col-12 col-md-3 bd-topbar-whitespace site-navigation show"></div>
+        <div class="col pl-md-4 topbar-main">
+            
+            <button id="navbar-toggler" class="navbar-toggler ml-0" type="button" data-toggle="collapse"
+                data-toggle="tooltip" data-placement="bottom" data-target=".site-navigation" aria-controls="navbar-menu"
+                aria-expanded="true" aria-label="Toggle navigation" aria-controls="site-navigation"
+                title="Toggle navigation" data-toggle="tooltip" data-placement="left">
+                <i class="fas fa-bars"></i>
+                <i class="fas fa-arrow-left"></i>
+                <i class="fas fa-arrow-up"></i>
+            </button>
+            
+            
+<div class="dropdown-buttons-trigger">
+    <button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn" aria-label="Download this page"><i
+            class="fas fa-download"></i></button>
+
+    <div class="dropdown-buttons">
+        <!-- ipynb file if we had a myst markdown file -->
+        
+        <!-- Download raw file -->
+        <a class="dropdown-buttons" href="_sources/README.md"><button type="button"
+                class="btn btn-secondary topbarbtn" title="Download source file" data-toggle="tooltip"
+                data-placement="left">.md</button></a>
+        <!-- Download PDF via print -->
+        <button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="Print to PDF"
+                onclick="printPdf(this)" data-toggle="tooltip" data-placement="left">.pdf</button>
+    </div>
+</div>
+
+            <!-- Source interaction buttons -->
+
+<div class="dropdown-buttons-trigger">
+    <button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn"
+        aria-label="Connect with source repository"><i class="fab fa-github"></i></button>
+    <div class="dropdown-buttons sourcebuttons">
+        <a class="repository-button"
+            href="https://github.com/ssm-jax/ssm-book"><button type="button" class="btn btn-secondary topbarbtn"
+                data-toggle="tooltip" data-placement="left" title="Source repository"><i
+                    class="fab fa-github"></i>repository</button></a>
+        <a class="issues-button"
+            href="https://github.com/ssm-jax/ssm-book/issues/new?title=Issue%20on%20page%20%2FREADME.html&body=Your%20issue%20content%20here."><button
+                type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip" data-placement="left"
+                title="Open an issue"><i class="fas fa-lightbulb"></i>open issue</button></a>
+        
+    </div>
+</div>
+
+            <!-- Full screen (wrap in <a> to have style consistency -->
+
+<a class="full-screen-button"><button type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip"
+        data-placement="bottom" onclick="toggleFullScreen()" aria-label="Fullscreen mode"
+        title="Fullscreen mode"><i
+            class="fas fa-expand"></i></button></a>
+
+            <!-- Launch buttons -->
+
+        </div>
+
+        <!-- Table of contents -->
+        <div class="d-none d-md-block col-md-2 bd-toc show noprint">
+            
+        </div>
+    </div>
+</div>
+    <div id="main-content" class="row">
+        <div class="col-12 col-md-9 pl-md-3 pr-md-0">
+            <!-- Table of contents that is only displayed when printing the page -->
+            <div id="jb-print-docs-body" class="onlyprint">
+                <h1>ssm-book</h1>
+                <!-- Table of contents -->
+                <div id="print-main-content">
+                    <div id="jb-print-toc">
+                        
+                    </div>
+                </div>
+            </div>
+            
+              <div>
+                
+  <div class="tex2jax_ignore mathjax_ignore section" id="ssm-book">
+<h1>ssm-book<a class="headerlink" href="#ssm-book" title="Permalink to this headline">¶</a></h1>
+<p>Interactive textbook on state-space models.
+The rendered content can be found at <a class="reference external" href="https://probml.github.io/ssm-book/root.html">https://probml.github.io/ssm-book/root.html</a>.</p>
+</div>
+
+    <script type="text/x-thebe-config">
+    {
+        requestKernel: true,
+        binderOptions: {
+            repo: "binder-examples/jupyter-stacks-datascience",
+            ref: "master",
+        },
+        codeMirrorConfig: {
+            theme: "abcdef",
+            mode: "python"
+        },
+        kernelOptions: {
+            kernelName: "python3",
+            path: "./."
+        },
+        predefinedOutput: true
+    }
+    </script>
+    <script>kernelName = 'python3'</script>
+
+              </div>
+              
+            
+                <!-- Previous / next buttons -->
+<div class='prev-next-area'>
+</div>
+            
+        </div>
+    </div>
+    <footer class="footer">
+  <p>
+    
+      By Kevin Murphy, Scott Linderman, et al.<br/>
+    
+        &copy; Copyright 2021.<br/>
+  </p>
+</footer>
+</main>
+
+
+      </div>
+    </div>
+  
+  <script src="_static/js/index.be7d3bbb2ef33a8344ce.js"></script>
+
+  </body>
+</html>

BIN
_build/html/_images/casino.png


BIN
_build/html/_images/cat_dog.jpg


BIN
_build/html/_images/scratch_2_0.png


File diff suppressed because it is too large
+ 1 - 0
_build/html/_panels_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css


+ 7 - 0
_build/html/_panels_static/panels-variables.06eb56fa6e07937060861dad626602ad.css

@@ -0,0 +1,7 @@
+:root {
+--tabs-color-label-active: hsla(231, 99%, 66%, 1);
+--tabs-color-label-inactive: rgba(178, 206, 245, 0.62);
+--tabs-color-overline: rgb(207, 236, 238);
+--tabs-color-underline: rgb(207, 236, 238);
+--tabs-size-label: 1rem;
+}

+ 3 - 0
_build/html/_sources/README.md

@@ -0,0 +1,3 @@
+# ssm-book
+Interactive textbook on state-space models.
+The rendered content can be found at [https://probml.github.io/ssm-book/root.html](https://probml.github.io/ssm-book/root.html).

+ 5 - 0
_build/html/_sources/bib.md

@@ -0,0 +1,5 @@
+# Bibliography
+
+
+```{bibliography}
+```

+ 13 - 0
_build/html/_sources/chapters/adf/adf_index.md

@@ -0,0 +1,13 @@
+
+
+(ch:ADF)=
+# Assumed Density Filtering
+
+
+
+
+
+
+
+
+

+ 39 - 0
_build/html/_sources/chapters/blank.ipynb

@@ -0,0 +1,39 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "(chap:my-chap)=\n",
+    "# Chapter title\n",
+    "\n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 9 - 0
_build/html/_sources/chapters/bnp/bnp_index.md

@@ -0,0 +1,9 @@
+
+
+(ch:BNP)=
+# Bayesian non-parametric SSMs
+
+
+
+
+

+ 14 - 0
_build/html/_sources/chapters/changepoint/changepoint_index.md

@@ -0,0 +1,14 @@
+
+
+(ch:changepoint)=
+# Changepoint detection
+
+
+
+{cite}`Agudelo-Espana2020`, {cite}`Adams2007`, {cite}`Fearnhead04`, {cite}`Fearnhead06`, {cite}`Fearnhead07`, 
+{cite}`Fearnhead11`
+
+
+
+
+

+ 19 - 0
_build/html/_sources/chapters/control/control_index.md

@@ -0,0 +1,19 @@
+
+
+(ch:control)=
+# Optimal control
+
+
+{cite}`Botvinick2012`, {cite}`Kappen2012`, {cite}`Rawlik2012`
+
+## LQR
+
+## MPC
+
+
+
+
+
+
+
+

+ 10 - 0
_build/html/_sources/chapters/ensemble/ensemble_index.md

@@ -0,0 +1,10 @@
+
+
+(ch:ensemble)=
+# Data assimilation using Ensemble Kalman filter
+
+
+{cite}`Evensen2009`, {cite}`Roth2017enkf`
+
+
+

+ 32 - 0
_build/html/_sources/chapters/extended/extended_filter.ipynb

@@ -0,0 +1,32 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Extended Kalman filtering"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 7 - 0
_build/html/_sources/chapters/extended/extended_index.md

@@ -0,0 +1,7 @@
+
+
+(ch:extended)=
+# Extended (linearized) methods 
+
+```{tableofcontents}
+```

+ 34 - 0
_build/html/_sources/chapters/extended/extended_parallel.ipynb

@@ -0,0 +1,34 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Parallel extended Kalman smoothing\n",
+    "\n",
+    "{cite}`Sarkka2020icassp`\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 32 - 0
_build/html/_sources/chapters/extended/extended_smoother.ipynb

@@ -0,0 +1,32 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Extended Kalman smoother"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 13 - 0
_build/html/_sources/chapters/gp/gp_index.md

@@ -0,0 +1,13 @@
+
+
+(ch:GP)=
+# Markovian Gaussian processes
+
+
+
+
+
+
+
+
+

+ 32 - 0
_build/html/_sources/chapters/hmm/hmm_filter.ipynb

@@ -0,0 +1,32 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# HMM filtering (forwards algorithm)\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 10 - 0
_build/html/_sources/chapters/hmm/hmm_index.md

@@ -0,0 +1,10 @@
+(ch:hmm)=
+# Inference in discrete SSMs 
+
+This chapter covers inference in HMMs.
+
+
+```{tableofcontents}
+```
+
+See (sec:casino-ex).

+ 36 - 0
_build/html/_sources/chapters/hmm/hmm_parallel.ipynb

@@ -0,0 +1,36 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Parallel HMM  smoothing\n",
+    "\n",
+    "{cite}`Hassan2021`\n",
+    "\n",
+    "\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 32 - 0
_build/html/_sources/chapters/hmm/hmm_sampling.ipynb

@@ -0,0 +1,32 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Forwards-filtering backwards-sampling algorithm\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 51 - 0
_build/html/_sources/chapters/hmm/hmm_smoother.ipynb

@@ -0,0 +1,51 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# HMM smoothing (forwards-backwards algorithm)\n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Forwards filter, backwards smoother algorithm"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Two-filter algorithm"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 32 - 0
_build/html/_sources/chapters/hmm/hmm_viterbi.ipynb

@@ -0,0 +1,32 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Viterbi algorithm\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 35 - 0
_build/html/_sources/chapters/learning/em.ipynb

@@ -0,0 +1,35 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "(sec:em)=\n",
+    "# Expectation Maximization (EM)\n",
+    "\n",
+    "{cite}`Ghahramani96a`\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.8"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 7 - 0
_build/html/_sources/chapters/learning/learning_index.md

@@ -0,0 +1,7 @@
+
+
+(ch:learning)=
+# Offline parameter estimation (learning)
+
+```{tableofcontents}
+```

+ 34 - 0
_build/html/_sources/chapters/learning/mcmc.ipynb

@@ -0,0 +1,34 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "(sec:mcmc)=\n",
+    "# Markov Chain Monte Carlo (MCMC)\n",
+    "\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.8"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 34 - 0
_build/html/_sources/chapters/learning/sgd.ipynb

@@ -0,0 +1,34 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "(sec:sgd)=\n",
+    "# Stochastic Gradient Descent (SGD)\n",
+    "\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.8"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 35 - 0
_build/html/_sources/chapters/learning/vb.ipynb

@@ -0,0 +1,35 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "\n",
+    "(sec:VB)=\n",
+    "# Variational Bayes (VB)\n",
+    "\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.8"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 32 - 0
_build/html/_sources/chapters/lgssm/kalman_filter.ipynb

@@ -0,0 +1,32 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Kalman filtering"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 37 - 0
_build/html/_sources/chapters/lgssm/kalman_parallel.ipynb

@@ -0,0 +1,37 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Parallel Kalman Smoother\n",
+    "\n",
+    "{cite}`Sarkka2021`\n",
+    "\n",
+    "\n",
+    "\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 32 - 0
_build/html/_sources/chapters/lgssm/kalman_sampling.ipynb

@@ -0,0 +1,32 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Forwards-filtering backwards sampling"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 32 - 0
_build/html/_sources/chapters/lgssm/kalman_smoother.ipynb

@@ -0,0 +1,32 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Kalman (RTS) smoother"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 7 - 0
_build/html/_sources/chapters/lgssm/lgssm_index.md

@@ -0,0 +1,7 @@
+
+
+(ch:lgssm)=
+# Inference in linear-Gaussian SSMs
+
+```{tableofcontents}
+```

+ 12 - 0
_build/html/_sources/chapters/ode/ode_index.md

@@ -0,0 +1,12 @@
+
+
+(ch:ODE)=
+# Differential equations and SSMs
+
+
+{cite}`Tronarp2019`, {cite}`Sarkka2019book`, {cite}`HennigBook`
+
+
+
+
+

+ 10 - 0
_build/html/_sources/chapters/pf/pf_index.md

@@ -0,0 +1,10 @@
+
+
+(ch:PF)=
+# Particle filtering
+
+
+
+
+
+

+ 12 - 0
_build/html/_sources/chapters/postlin/postlin_index.md

@@ -0,0 +1,12 @@
+
+
+(ch:postlin)=
+# Posterior linearization
+
+
+{cite}`Garcia-Fernandez2017`, {cite}`Tronarp2018`, {cite}`Garcia-Fernandez2019`
+
+
+
+
+

+ 12 - 0
_build/html/_sources/chapters/quadrature/quadrature_index.md

@@ -0,0 +1,12 @@
+
+
+(ch:quadrature)=
+# Quadrature and cubature methods
+
+
+
+
+
+
+
+

File diff suppressed because it is too large
+ 204 - 0
_build/html/_sources/chapters/scratch.ipynb


+ 116 - 0
_build/html/_sources/chapters/scratch.md

@@ -0,0 +1,116 @@
+---
+jupytext:
+  cell_metadata_filter: -all
+  formats: md:myst
+  text_representation:
+    extension: .md
+    format_name: myst
+kernelspec:
+  display_name: Python 3
+  language: python
+  name: python3
+---
+
+(ch:intro)=
+# Scratchpad
+
+
+In this chapter, we do blah.
+Specifically
+
+- foo
+- bar.
+- baz
+
+For more details, see 
+{ref}`ch:hmm` and  {cite}`Sarkka13`.
+
+
+## Python
+
+We\'re now ready to start coding.
+
+```{code-cell}
+from matplotlib import rcParams, cycler
+import matplotlib.pyplot as plt
+import numpy as np
+plt.ion()
+```
+
+```{code-cell}
+# Fixing random state for reproducibility
+np.random.seed(19680801)
+
+N = 10
+data = [np.logspace(0, 1, 100) + np.random.randn(100) + ii for ii in range(N)]
+data = np.array(data).T
+cmap = plt.cm.coolwarm
+rcParams['axes.prop_cycle'] = cycler(color=cmap(np.linspace(0, 1, N)))
+
+
+from matplotlib.lines import Line2D
+custom_lines = [Line2D([0], [0], color=cmap(0.), lw=4),
+                Line2D([0], [0], color=cmap(.5), lw=4),
+                Line2D([0], [0], color=cmap(1.), lw=4)]
+
+fig, ax = plt.subplots(figsize=(10, 5))
+lines = ax.plot(data)
+ax.legend(custom_lines, ['Cold', 'Medium', 'Hot']);
+```
+
+```{code-cell}
+import matplotlib.pyplot as plt
+import numpy as np
+import jax
+import jax.numpy as jnp
+
+print(jax.devices())
+```
+
+## Images
+
+
+<!---
+![](https://myst-parser.readthedocs.io/en/latest/_static/logo-wide.svg)
+
+
+<img src="https://github.com/probml/probml-notebooks/blob/main/images/cat_dog.jpg"
+style="height:200">
+-->
+
+```{figure} /figures/cat_dog.jpg
+:scale: 50%
+:name: cat_dog
+
+A photo of a cat and a dog.
+```
+
+```{figure} /figures/cat_dog.jpg
+:scale: 50%
+:name: cat_dog2
+
+Another photo of a cat and a dog.
+```
+
+In {numref}`Figure %s <cat_dog>` we show catdog.
+In {numref}`Figure %s <cat_dog2>` we show catdog2, its twin.
+
+
+## Math
+
+We have $E= mc^2$, and also
+
+```{math}
+:label: foo
+a x^2 + bx+ c = 0
+```
+
+From {eq}`foo`, it follows that
+
+$$
+\begin{align}
+0 &= a x^2 + bx+ c \\
+0 &= a x^2 + bx+ c 
+\end{align}
+$$
+

+ 14 - 0
_build/html/_sources/chapters/smc/smc_index.md

@@ -0,0 +1,14 @@
+
+
+(ch:SMC)=
+# Sequential Monte Carlo
+
+{cite}`Chopin2020`
+
+
+
+
+
+
+
+

+ 37 - 0
_build/html/_sources/chapters/ssm/deep.ipynb

@@ -0,0 +1,37 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Deep SSMs\n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 612 - 0
_build/html/_sources/chapters/ssm/hmm.ipynb

@@ -0,0 +1,612 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "(sec:hmm-ex)=\n",
+    "# Hidden Markov Models\n",
+    "\n",
+    "In this section, we introduce Hidden Markov Models (HMMs)."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Boilerplate"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Collecting jax[cpu]\n",
+      "  Downloading jax-0.3.5.tar.gz (946 kB)\n",
+      "\u001b[K     |████████████████████████████████| 946 kB 2.7 MB/s eta 0:00:01\n",
+      "\u001b[?25hCollecting absl-py\n",
+      "  Downloading absl_py-1.0.0-py3-none-any.whl (126 kB)\n",
+      "\u001b[K     |████████████████████████████████| 126 kB 47.7 MB/s eta 0:00:01\n",
+      "\u001b[?25hCollecting numpy>=1.19\n",
+      "  Downloading numpy-1.22.3-cp38-cp38-macosx_10_14_x86_64.whl (17.6 MB)\n",
+      "\u001b[K     |████████████████████████████████| 17.6 MB 47.5 MB/s eta 0:00:01\n",
+      "\u001b[?25hCollecting opt_einsum\n",
+      "  Using cached opt_einsum-3.3.0-py3-none-any.whl (65 kB)\n",
+      "Collecting scipy>=1.2.1\n",
+      "  Downloading scipy-1.8.0-cp38-cp38-macosx_12_0_universal2.macosx_10_9_x86_64.whl (55.3 MB)\n",
+      "\u001b[K     |████████████████████████████████| 55.3 MB 73.1 MB/s eta 0:00:01\n",
+      "\u001b[?25hCollecting typing_extensions\n",
+      "  Using cached typing_extensions-4.1.1-py3-none-any.whl (26 kB)\n",
+      "Collecting jaxlib==0.3.5\n",
+      "  Downloading jaxlib-0.3.5-cp38-none-macosx_10_9_x86_64.whl (70.5 MB)\n",
+      "\u001b[K     |████████████████████████████████| 70.5 MB 723 kB/s  eta 0:00:01\n",
+      "\u001b[?25hCollecting flatbuffers<3.0,>=1.12\n",
+      "  Using cached flatbuffers-2.0-py2.py3-none-any.whl (26 kB)\n",
+      "Requirement already satisfied: six in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from absl-py->jax[cpu]) (1.16.0)\n",
+      "Building wheels for collected packages: jax\n",
+      "  Building wheel for jax (setup.py) ... \u001b[?25ldone\n",
+      "\u001b[?25h  Created wheel for jax: filename=jax-0.3.5-py3-none-any.whl size=1095861 sha256=6886baa70817bbac3b5797b3720dcb81e49097f61cee7d2e1255823ea32ccad8\n",
+      "  Stored in directory: /Users/kpmurphy/Library/Caches/pip/wheels/05/30/aa/908988293721511b4b29e0aadf9b5d133d0f14f6c0a188e764\n",
+      "Successfully built jax\n",
+      "Installing collected packages: numpy, typing-extensions, scipy, opt-einsum, flatbuffers, absl-py, jaxlib, jax\n",
+      "Successfully installed absl-py-1.0.0 flatbuffers-2.0 jax-0.3.5 jaxlib-0.3.5 numpy-1.22.3 opt-einsum-3.3.0 scipy-1.8.0 typing-extensions-4.1.1\n",
+      "Note: you may need to restart the kernel to use updated packages.\n",
+      "Collecting git+https://github.com/probml/jsl\n",
+      "  Cloning https://github.com/probml/jsl to /private/var/folders/mn/vt7cgfsx6zs9vblhvbbk7pf8003xtr/T/pip-req-build-i8seqdiw\n",
+      "  Running command git clone -q https://github.com/probml/jsl /private/var/folders/mn/vt7cgfsx6zs9vblhvbbk7pf8003xtr/T/pip-req-build-i8seqdiw\n",
+      "Collecting chex\n",
+      "  Downloading chex-0.1.2-py3-none-any.whl (72 kB)\n",
+      "\u001b[K     |████████████████████████████████| 72 kB 1.3 MB/s eta 0:00:011\n",
+      "\u001b[?25hCollecting dataclasses\n",
+      "  Using cached dataclasses-0.6-py3-none-any.whl (14 kB)\n",
+      "Requirement already satisfied: jaxlib in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from jsl==0.0.0) (0.3.5)\n",
+      "Requirement already satisfied: jax in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from jsl==0.0.0) (0.3.5)\n",
+      "Collecting matplotlib\n",
+      "  Downloading matplotlib-3.5.1-cp38-cp38-macosx_10_9_x86_64.whl (7.3 MB)\n",
+      "\u001b[K     |████████████████████████████████| 7.3 MB 3.9 MB/s eta 0:00:01\n",
+      "\u001b[?25hCollecting tensorflow_probability\n",
+      "  Using cached tensorflow_probability-0.16.0-py2.py3-none-any.whl (6.3 MB)\n",
+      "Collecting dm-tree>=0.1.5\n",
+      "  Using cached dm_tree-0.1.6-cp38-cp38-macosx_10_14_x86_64.whl (95 kB)\n",
+      "Requirement already satisfied: absl-py>=0.9.0 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from chex->jsl==0.0.0) (1.0.0)\n",
+      "Requirement already satisfied: numpy>=1.18.0 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from chex->jsl==0.0.0) (1.22.3)\n",
+      "Collecting toolz>=0.9.0\n",
+      "  Downloading toolz-0.11.2-py3-none-any.whl (55 kB)\n",
+      "\u001b[K     |████████████████████████████████| 55 kB 11.3 MB/s eta 0:00:01\n",
+      "\u001b[?25hRequirement already satisfied: six in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from absl-py>=0.9.0->chex->jsl==0.0.0) (1.16.0)\n",
+      "Requirement already satisfied: typing-extensions in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from jax->jsl==0.0.0) (4.1.1)\n",
+      "Requirement already satisfied: scipy>=1.2.1 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from jax->jsl==0.0.0) (1.8.0)\n",
+      "Requirement already satisfied: opt-einsum in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from jax->jsl==0.0.0) (3.3.0)\n",
+      "Requirement already satisfied: flatbuffers<3.0,>=1.12 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from jaxlib->jsl==0.0.0) (2.0)\n",
+      "Collecting cycler>=0.10\n",
+      "  Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)\n",
+      "Collecting kiwisolver>=1.0.1\n",
+      "  Downloading kiwisolver-1.4.2-cp38-cp38-macosx_10_9_x86_64.whl (65 kB)\n",
+      "\u001b[K     |████████████████████████████████| 65 kB 8.5 MB/s  eta 0:00:01\n",
+      "\u001b[?25hCollecting fonttools>=4.22.0\n",
+      "  Downloading fonttools-4.32.0-py3-none-any.whl (900 kB)\n",
+      "\u001b[K     |████████████████████████████████| 900 kB 35.8 MB/s eta 0:00:01\n",
+      "\u001b[?25hRequirement already satisfied: pyparsing>=2.2.1 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from matplotlib->jsl==0.0.0) (3.0.7)\n",
+      "Requirement already satisfied: packaging>=20.0 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from matplotlib->jsl==0.0.0) (21.3)\n",
+      "Requirement already satisfied: python-dateutil>=2.7 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from matplotlib->jsl==0.0.0) (2.8.2)\n",
+      "Collecting pillow>=6.2.0\n",
+      "  Downloading Pillow-9.1.0-cp38-cp38-macosx_10_9_x86_64.whl (3.1 MB)\n",
+      "\u001b[K     |████████████████████████████████| 3.1 MB 76.6 MB/s eta 0:00:01\n",
+      "\u001b[?25hCollecting gast>=0.3.2\n",
+      "  Downloading gast-0.5.3-py3-none-any.whl (19 kB)\n",
+      "Requirement already satisfied: decorator in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from tensorflow_probability->jsl==0.0.0) (5.1.1)\n",
+      "Collecting cloudpickle>=1.3\n",
+      "  Downloading cloudpickle-2.0.0-py3-none-any.whl (25 kB)\n",
+      "Building wheels for collected packages: jsl\n",
+      "  Building wheel for jsl (setup.py) ... \u001b[?25ldone\n",
+      "\u001b[?25h  Created wheel for jsl: filename=jsl-0.0.0-py3-none-any.whl size=77852 sha256=e7365293dc97e2b3e72bf42cc19db7d7e355abec312fc4d87961fa2044fa06f0\n",
+      "  Stored in directory: /private/var/folders/mn/vt7cgfsx6zs9vblhvbbk7pf8003xtr/T/pip-ephem-wheel-cache-63vxzlng/wheels/ed/8b/bf/0105dc839fecf1fc8db14f7267a6ce5ee876324b58565b359f\n",
+      "Successfully built jsl\n",
+      "Installing collected packages: toolz, pillow, kiwisolver, gast, fonttools, dm-tree, cycler, cloudpickle, tensorflow-probability, matplotlib, dataclasses, chex, jsl\n",
+      "Successfully installed chex-0.1.2 cloudpickle-2.0.0 cycler-0.11.0 dataclasses-0.6 dm-tree-0.1.6 fonttools-4.32.0 gast-0.5.3 jsl-0.0.0 kiwisolver-1.4.2 matplotlib-3.5.1 pillow-9.1.0 tensorflow-probability-0.16.0 toolz-0.11.2\n",
+      "Note: you may need to restart the kernel to use updated packages.\n",
+      "Collecting rich\n",
+      "  Downloading rich-12.2.0-py3-none-any.whl (229 kB)\n",
+      "\u001b[K     |████████████████████████████████| 229 kB 2.9 MB/s eta 0:00:01\n",
+      "\u001b[?25hRequirement already satisfied: typing-extensions<5.0,>=4.0.0 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from rich) (4.1.1)\n",
+      "Requirement already satisfied: pygments<3.0.0,>=2.6.0 in /opt/anaconda3/envs/scripts/lib/python3.8/site-packages (from rich) (2.11.2)\n",
+      "Collecting commonmark<0.10.0,>=0.9.0\n",
+      "  Using cached commonmark-0.9.1-py2.py3-none-any.whl (51 kB)\n",
+      "Installing collected packages: commonmark, rich\n",
+      "Successfully installed commonmark-0.9.1 rich-12.2.0\n",
+      "Note: you may need to restart the kernel to use updated packages.\n"
+     ]
+    }
+   ],
+   "source": [
+    "# Install necessary libraries\n",
+    "\n",
+    "try:\n",
+    "    import jax\n",
+    "except:\n",
+    "    # For cuda version, see https://github.com/google/jax#installation\n",
+    "    %pip install --upgrade \"jax[cpu]\" \n",
+    "    import jax\n",
+    "\n",
+    "try:\n",
+    "    import jsl\n",
+    "except:\n",
+    "    %pip install git+https://github.com/probml/jsl\n",
+    "    import jsl\n",
+    "\n",
+    "try:\n",
+    "    import rich\n",
+    "except:\n",
+    "    %pip install rich\n",
+    "    import rich\n",
+    "\n",
+    "\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# Import standard libraries\n",
+    "\n",
+    "import abc\n",
+    "from dataclasses import dataclass\n",
+    "import functools\n",
+    "import itertools\n",
+    "\n",
+    "from typing import Any, Callable, NamedTuple, Optional, Union, Tuple\n",
+    "\n",
+    "import matplotlib.pyplot as plt\n",
+    "import numpy as np\n",
+    "\n",
+    "\n",
+    "import jax\n",
+    "import jax.numpy as jnp\n",
+    "from jax import lax, vmap, jit, grad\n",
+    "from jax.scipy.special import logit\n",
+    "from jax.nn import softmax\n",
+    "from functools import partial\n",
+    "from jax.random import PRNGKey, split\n",
+    "\n",
+    "import inspect\n",
+    "import inspect as py_inspect\n",
+    "from rich import inspect as r_inspect\n",
+    "from rich import print as r_print\n",
+    "\n",
+    "def print_source(fname):\n",
+    "    r_print(py_inspect.getsource(fname))"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Utility code"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "\n",
+    "\n",
+    "def normalize(u, axis=0, eps=1e-15):\n",
+    "    '''\n",
+    "    Normalizes the values within the axis in a way that they sum up to 1.\n",
+    "    Parameters\n",
+    "    ----------\n",
+    "    u : array\n",
+    "    axis : int\n",
+    "    eps : float\n",
+    "        Threshold for the alpha values\n",
+    "    Returns\n",
+    "    -------\n",
+    "    * array\n",
+    "        Normalized version of the given matrix\n",
+    "    * array(seq_len, n_hidden) :\n",
+    "        The values of the normalizer\n",
+    "    '''\n",
+    "    u = jnp.where(u == 0, 0, jnp.where(u < eps, eps, u))\n",
+    "    c = u.sum(axis=axis)\n",
+    "    c = jnp.where(c == 0, 1, c)\n",
+    "    return u / c, c"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "(sec:casino-ex)=\n",
+    "## Example: Casino HMM\n",
+    "\n",
+    "We first create the \"Ocassionally dishonest casino\" model from {cite}`Durbin98`.\n",
+    "\n",
+    "```{figure} /figures/casino.png\n",
+    ":scale: 50%\n",
+    ":name: casino-fig\n",
+    "\n",
+    "Illustration of the casino HMM.\n",
+    "```\n",
+    "\n",
+    "There are 2 hidden states, each of which emit 6 possible observations."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)\n"
+     ]
+    }
+   ],
+   "source": [
+    "# state transition matrix\n",
+    "A = np.array([\n",
+    "    [0.95, 0.05],\n",
+    "    [0.10, 0.90]\n",
+    "])\n",
+    "\n",
+    "# observation matrix\n",
+    "B = np.array([\n",
+    "    [1/6, 1/6, 1/6, 1/6, 1/6, 1/6], # fair die\n",
+    "    [1/10, 1/10, 1/10, 1/10, 1/10, 5/10] # loaded die\n",
+    "])\n",
+    "\n",
+    "pi, _ = normalize(np.array([1, 1]))\n",
+    "pi = np.array(pi)\n",
+    "\n",
+    "\n",
+    "(nstates, nobs) = np.shape(B)\n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Let's make a little data structure to store all the parameters.\n",
+    "We use NamedTuple rather than dataclass, since we assume these are immutable.\n",
+    "(Also, standard python dataclass does not work well with JAX, which requires parameters to be\n",
+    "pytrees, as discussed in https://github.com/google/jax/issues/2371)."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 74,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "HMM(trans_mat=array([[0.95, 0.05],\n",
+      "       [0.1 , 0.9 ]]), obs_mat=array([[0.16666667, 0.16666667, 0.16666667, 0.16666667, 0.16666667,\n",
+      "        0.16666667],\n",
+      "       [0.1       , 0.1       , 0.1       , 0.1       , 0.1       ,\n",
+      "        0.5       ]]), init_dist=array([0.5, 0.5], dtype=float32))\n",
+      "<class 'numpy.ndarray'>\n",
+      "HMM(trans_mat=DeviceArray([[0.95, 0.05],\n",
+      "             [0.1 , 0.9 ]], dtype=float32), obs_mat=DeviceArray([[0.16666667, 0.16666667, 0.16666667, 0.16666667, 0.16666667,\n",
+      "              0.16666667],\n",
+      "             [0.1       , 0.1       , 0.1       , 0.1       , 0.1       ,\n",
+      "              0.5       ]], dtype=float32), init_dist=DeviceArray([0.5, 0.5], dtype=float32))\n",
+      "<class 'jaxlib.xla_extension.DeviceArray'>\n"
+     ]
+    }
+   ],
+   "source": [
+    "Array = Union[np.array, jnp.array]\n",
+    "\n",
+    "class HMM(NamedTuple):\n",
+    "    trans_mat: Array  # A : (n_states, n_states)\n",
+    "    obs_mat: Array  # B : (n_states, n_obs)\n",
+    "    init_dist: Array  # pi : (n_states)\n",
+    "\n",
+    "params_np = HMM(A, B, pi)\n",
+    "print(params_np)\n",
+    "print(type(params_np.trans_mat))\n",
+    "\n",
+    "\n",
+    "params = jax.tree_map(lambda x: jnp.array(x), params_np)\n",
+    "print(params)\n",
+    "print(type(params.trans_mat))"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Sampling from the joint\n",
+    "\n",
+    "Let's write code to sample from this model. \n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### Numpy version\n",
+    "\n",
+    "First we code it in numpy using a for loop."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 30,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def hmm_sample_np(params, seq_len, random_state=0):\n",
+    "    np.random.seed(random_state)\n",
+    "    trans_mat, obs_mat, init_dist = params.trans_mat, params.obs_mat, params.init_dist\n",
+    "    n_states, n_obs = obs_mat.shape\n",
+    "    state_seq = np.zeros(seq_len, dtype=int)\n",
+    "    obs_seq = np.zeros(seq_len, dtype=int)\n",
+    "    for t in range(seq_len):\n",
+    "        if t==0:\n",
+    "            zt = np.random.choice(n_states, p=init_dist)\n",
+    "        else:\n",
+    "            zt = np.random.choice(n_states, p=trans_mat[zt])\n",
+    "        yt = np.random.choice(n_obs, p=obs_mat[zt])\n",
+    "        state_seq[t] = zt\n",
+    "        obs_seq[t] = yt\n",
+    "\n",
+    "    return state_seq, obs_seq"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 75,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0\n",
+      " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
+      " 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n",
+      "[4 1 0 2 3 4 5 4 3 1 5 4 5 0 5 2 5 3 5 4 5 5 4 2 1 4 1 0 0 4 2 2 3 3 3 0 4\n",
+      " 0 2 4 3 2 5 5 3 5 3 1 3 3 3 2 3 5 5 0 4 4 5 0 0 1 3 5 1 5 0 1 2 4 0 0 0 4\n",
+      " 0 5 1 4 3 5 4 5 0 2 3 5 2 4 1 2 1 0 4 3 5 0 4 5 1 5]\n"
+     ]
+    }
+   ],
+   "source": [
+    "seq_len = 100\n",
+    "state_seq, obs_seq = hmm_sample_np(params_np, seq_len, random_state=1)\n",
+    "print(state_seq)\n",
+    "print(obs_seq)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### JAX version\n",
+    "\n",
+    "Now let's write a JAX version using jax.lax.scan (for the inter-dependent states) and vmap (for the observations).\n",
+    "This is harder to read than the numpy version, but faster."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 91,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#@partial(jit, static_argnums=(1,))\n",
+    "def markov_chain_sample(rng_key, init_dist, trans_mat, seq_len):\n",
+    "    n_states = len(init_dist)\n",
+    "\n",
+    "    def draw_state(prev_state, key):\n",
+    "        state = jax.random.choice(key, n_states, p=trans_mat[prev_state])\n",
+    "        return state, state\n",
+    "\n",
+    "    rng_key, rng_state = jax.random.split(rng_key, 2)\n",
+    "    keys = jax.random.split(rng_state, seq_len - 1)\n",
+    "    initial_state = jax.random.choice(rng_key, n_states, p=init_dist)\n",
+    "    final_state, states = jax.lax.scan(draw_state, initial_state, keys)\n",
+    "    state_seq = jnp.append(jnp.array([initial_state]), states)\n",
+    "\n",
+    "    return state_seq"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 90,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#@partial(jit, static_argnums=(1,))\n",
+    "def hmm_sample(rng_key, params, seq_len):\n",
+    "\n",
+    "    trans_mat, obs_mat, init_dist = params.trans_mat, params.obs_mat, params.init_dist\n",
+    "    n_states, n_obs = obs_mat.shape\n",
+    "    rng_key, rng_obs = jax.random.split(rng_key, 2)\n",
+    "    state_seq = markov_chain_sample(rng_key, init_dist, trans_mat, seq_len)\n",
+    "\n",
+    "    def draw_obs(z, key):\n",
+    "        obs = jax.random.choice(key, n_obs, p=obs_mat[z])\n",
+    "        return obs\n",
+    "\n",
+    "    keys = jax.random.split(rng_obs, seq_len)\n",
+    "    obs_seq = jax.vmap(draw_obs, in_axes=(0, 0))(state_seq, keys)\n",
+    "    \n",
+    "    return state_seq, obs_seq"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 70,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "#@partial(jit, static_argnums=(1,))\n",
+    "def hmm_sample2(rng_key, params, seq_len):\n",
+    "\n",
+    "    trans_mat, obs_mat, init_dist = params.trans_mat, params.obs_mat, params.init_dist\n",
+    "    n_states, n_obs = obs_mat.shape\n",
+    "\n",
+    "    def draw_state(prev_state, key):\n",
+    "        state = jax.random.choice(key, n_states, p=trans_mat[prev_state])\n",
+    "        return state, state\n",
+    "\n",
+    "    rng_key, rng_state, rng_obs = jax.random.split(rng_key, 3)\n",
+    "    keys = jax.random.split(rng_state, seq_len - 1)\n",
+    "    initial_state = jax.random.choice(rng_key, n_states, p=init_dist)\n",
+    "    final_state, states = jax.lax.scan(draw_state, initial_state, keys)\n",
+    "    state_seq = jnp.append(jnp.array([initial_state]), states)\n",
+    "\n",
+    "    def draw_obs(z, key):\n",
+    "        obs = jax.random.choice(key, n_obs, p=obs_mat[z])\n",
+    "        return obs\n",
+    "\n",
+    "    keys = jax.random.split(rng_obs, seq_len)\n",
+    "    obs_seq = jax.vmap(draw_obs, in_axes=(0, 0))(state_seq, keys)\n",
+    "\n",
+    "    return state_seq, obs_seq"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 93,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
+      " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\n",
+      " 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n",
+      "[5 5 2 2 0 0 0 1 3 3 2 2 5 1 5 1 0 2 2 4 2 5 1 5 5 0 0 4 2 4 3 2 3 4 1 0 5\n",
+      " 2 2 2 1 4 3 2 2 2 4 1 0 3 5 2 5 1 4 2 5 2 5 0 5 4 4 4 2 2 0 4 5 2 2 0 1 5\n",
+      " 1 3 4 5 1 5 0 5 1 5 1 2 4 5 3 4 5 4 0 4 0 2 4 5 3 3]\n"
+     ]
+    }
+   ],
+   "source": [
+    "\n",
+    "key = PRNGKey(2)\n",
+    "seq_len = 100\n",
+    "\n",
+    "state_seq, obs_seq = hmm_sample(key, params, seq_len)\n",
+    "print(state_seq)\n",
+    "print(obs_seq)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### Check correctness by computing empirical pairwise statistics\n",
+    "\n",
+    "We will compute the number of i->j transitions, and check that it is close to the true \n",
+    "A[i,j] transition probabilites."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 107,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "[0 0 1 1 1 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1\n",
+      " 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1 0\n",
+      " 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0\n",
+      " 0 0 1 1 1 1 1 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 0 0 0 0 0 1 0\n",
+      " 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 0 0 1 0 0 0 0\n",
+      " 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 0\n",
+      " 0 0 0 1 1 1 0 0 0 0 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 0 0 0 1 1 0 1 0 0 1 0 0\n",
+      " 0 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 1 1 1 1\n",
+      " 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1\n",
+      " 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 1 0 1 0 0 0\n",
+      " 0 0 0 0 0 0 0 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 1 0\n",
+      " 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0\n",
+      " 0 0 0 0 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 0 0 1\n",
+      " 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 1]\n",
+      "[[244.  93.]\n",
+      " [ 92.  70.]]\n",
+      "[[0.7240356  0.27596438]\n",
+      " [0.56790125 0.43209878]]\n"
+     ]
+    }
+   ],
+   "source": [
+    "import collections\n",
+    "def compute_counts(state_seq, nstates):\n",
+    "    wseq = np.array(state_seq)\n",
+    "    word_pairs = [pair for pair in zip(wseq[:-1], wseq[1:])]\n",
+    "    counter_pairs = collections.Counter(word_pairs)\n",
+    "    counts = np.zeros((nstates, nstates))\n",
+    "    for (k,v) in counter_pairs.items():\n",
+    "        counts[k[0], k[1]] = v\n",
+    "    return counts\n",
+    "\n",
+    "def normalize_counts(counts):\n",
+    "    ncounts = vmap(lambda v: normalize(v)[0], in_axes=0)(counts)\n",
+    "    return ncounts\n",
+    "\n",
+    "init_dist = jnp.array([1.0, 0.0])\n",
+    "trans_mat = jnp.array([[0.7, 0.3], [0.5, 0.5]])\n",
+    "rng_key = jax.random.PRNGKey(0)\n",
+    "seq_len = 500\n",
+    "state_seq = markov_chain_sample(rng_key, init_dist, trans_mat, seq_len)\n",
+    "print(state_seq)\n",
+    "\n",
+    "counts = compute_counts(state_seq, nstates=2)\n",
+    "print(counts)\n",
+    "\n",
+    "trans_mat_empirical = normalize_counts(counts)\n",
+    "print(trans_mat_empirical)\n",
+    "\n",
+    "assert jnp.allclose(trans_mat, trans_mat_empirical, atol=1e-1)\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.8"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 33 - 0
_build/html/_sources/chapters/ssm/hsmm.ipynb

@@ -0,0 +1,33 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Hidden Semi-Markov Models\n",
+    "\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 0 - 0
_build/html/_sources/chapters/ssm/lgssm.ipynb


Some files were not shown because too many files changed in this diff