From 2182bae1879905a6f23e631ccbccd10aecf913df Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 20 Jan 2017 15:33:02 +0100 Subject: [PATCH 1/2] Add the matrical form of the ODE + test github --- KalmanFilter-LinearPredatorPreyModel.ipynb | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/KalmanFilter-LinearPredatorPreyModel.ipynb b/KalmanFilter-LinearPredatorPreyModel.ipynb index a40340c..99de199 100644 --- a/KalmanFilter-LinearPredatorPreyModel.ipynb +++ b/KalmanFilter-LinearPredatorPreyModel.ipynb @@ -16,6 +16,36 @@ "If we do not know the source evolution, it can simply be simulated with persistence:\n", "$$ \\frac{dx_2}{dt} = 0 $$\n", "\n", + "If we use a forward Euler scheme, we have\n", + "$$\n", + "x_0(k+1) = 0.9 x_0(k) + 0.2 x_1(k)\\\\\n", + "x_1(k+1) = -0.2 x_0(k) + x_1(k) + x_2(k)\\\\\n", + "x_2(k+1) = x_2(k)\n", + "$$\n", + "\n", + "or in a matrical notation\n", + "\n", + "$$\n", + "\\begin{pmatrix}\n", + "0.9 & 0.2 &0 \\\\\n", + "-0.2 & 1 & 1\\\\\n", + "0 & 0& 1\n", + "\\end{pmatrix}\n", + "\\cdot\n", + "\\begin{pmatrix}\n", + "x_0\\\\\n", + "x_1\\\\\n", + "x_2\n", + "\\end{pmatrix}_{k+1}\n", + "=\n", + "\\begin{pmatrix}\n", + "x_0\\\\\n", + "x_1\\\\\n", + "x_2\n", + "\\end{pmatrix}_k\n", + "$$\n", + "\n", + "\n", "The model is implemented as a class, below. The `forecast` function of this class propagates in time not only the state ${\\bf x}=(x_0, x_1, x_2)$ of the model, but also the covariance matrix. This is made using a square-root decomposition of the covariance matrix and by propagating each column of this square-root. The class also includes basic plotting functions.\n", "\n", "Here, the problem tackled by data assimilation is to retrieve the source term ($x_2$) using observations of the other variables (predators, typically), and not knowing the seasonal dynamics of the source: We assume persistence." @@ -361,7 +391,7 @@ "metadata": { "kernelspec": { "display_name": "Python 2", - "language": "python", + "language": "python2", "name": "python2" }, "language_info": { @@ -374,7 +404,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.10" + "version": "2.7.13" } }, "nbformat": 4, From e54a882c1564b6bce046fb8e5fd462a7364bd901 Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 20 Jan 2017 15:35:54 +0100 Subject: [PATCH 2/2] Deleted remaining EOF... --- KalmanFilter-LinearPredatorPreyModel.ipynb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/KalmanFilter-LinearPredatorPreyModel.ipynb b/KalmanFilter-LinearPredatorPreyModel.ipynb index 99de199..1dd7fc4 100644 --- a/KalmanFilter-LinearPredatorPreyModel.ipynb +++ b/KalmanFilter-LinearPredatorPreyModel.ipynb @@ -33,19 +33,14 @@ "\\end{pmatrix}\n", "\\cdot\n", "\\begin{pmatrix}\n", - "x_0\\\\\n", - "x_1\\\\\n", - "x_2\n", + "x_0\\\\ x_1\\\\ x_2\n", "\\end{pmatrix}_{k+1}\n", "=\n", "\\begin{pmatrix}\n", - "x_0\\\\\n", - "x_1\\\\\n", - "x_2\n", + "x_0\\\\ x_1\\\\ x_2\n", "\\end{pmatrix}_k\n", "$$\n", "\n", - "\n", "The model is implemented as a class, below. The `forecast` function of this class propagates in time not only the state ${\\bf x}=(x_0, x_1, x_2)$ of the model, but also the covariance matrix. This is made using a square-root decomposition of the covariance matrix and by propagating each column of this square-root. The class also includes basic plotting functions.\n", "\n", "Here, the problem tackled by data assimilation is to retrieve the source term ($x_2$) using observations of the other variables (predators, typically), and not knowing the seasonal dynamics of the source: We assume persistence."