:align: center
:width: 90%
+.. include:: scripts/simple_KalmanFilter2.rst
+
+.. literalinclude:: scripts/simple_KalmanFilter2.py
+
.. ------------------------------------ ..
.. include:: snippets/Header2Algo06.rst
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+from numpy import array, random
+random.seed(1234567)
+Xtrue = -0.37727
+Yobs = []
+for i in range(51):
+ Yobs.append([random.normal(Xtrue, 0.1, size=(1,)),])
+#
+print("Estimation of a constant variable by filtering")
+print("----------------------------------------------")
+print(" Noisy measurements acquired on %i time steps"%(len(Yobs)-1,))
+print("")
+from adao import adaoBuilder
+case = adaoBuilder.New('')
+#
+case.setObservationOperator(Matrix = [1.])
+case.setObservationError (ScalarSparseMatrix = 0.1**2)
+#
+case.setEvolutionModel (Matrix = [1.])
+case.setEvolutionError (ScalarSparseMatrix = 1e-5)
+#
+case.setAlgorithmParameters(
+ Algorithm="KalmanFilter",
+ Parameters={
+ "StoreSupplementaryCalculations":[
+ "Analysis",
+ "APosterioriCovariance",
+ ],
+ },
+ )
+#
+XaStep, VaStep = 0., 1.
+for i in range(1,len(Yobs)):
+ case.setBackground (Vector = "%s"%float(XaStep))
+ case.setBackgroundError (ScalarSparseMatrix = "%s"%float(VaStep))
+ case.setObservation (Vector = Yobs[i])
+ case.execute( nextStep = True )
+ XaStep = case.get("Analysis")[-1]
+ VaStep = case.get("APosterioriCovariance")[-1]
+#
+Xa = case.get("Analysis")
+Pa = case.get("APosterioriCovariance")
+#
+print("")
+print(" Final a posteriori variance:",Pa[-1])
+print("")
--- /dev/null
+The Kalman filter can also be used for a **running analysis of the observations
+of a given dynamic model**. In this case, the analysis is conducted
+iteratively, at the arrival of each observation.
+
+The following example deals with the same simple dynamic system from the
+reference [Welch06]_. The essential difference consists in carrying out the
+execution of a Kalman step at the arrival of each observation provided
+iteratively. The keyword "*nextStep*", included in the execution order, allows
+to not store the background in duplicate of the previous analysis.
+
:align: center
:width: 90%
+.. include:: scripts/simple_KalmanFilter2.rst
+
+.. literalinclude:: scripts/simple_KalmanFilter2.py
+
.. ------------------------------------ ..
.. include:: snippets/Header2Algo06.rst
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+from numpy import array, random
+random.seed(1234567)
+Xtrue = -0.37727
+Yobs = []
+for i in range(51):
+ Yobs.append([random.normal(Xtrue, 0.1, size=(1,)),])
+#
+print("Estimation par filtrage d'une variable constante")
+print("------------------------------------------------")
+print(" Observations bruitées acquises sur %i pas de temps"%(len(Yobs)-1,))
+print("")
+from adao import adaoBuilder
+case = adaoBuilder.New('')
+#
+case.setObservationOperator(Matrix = [1.])
+case.setObservationError (ScalarSparseMatrix = 0.1**2)
+#
+case.setEvolutionModel (Matrix = [1.])
+case.setEvolutionError (ScalarSparseMatrix = 1e-5)
+#
+case.setAlgorithmParameters(
+ Algorithm="KalmanFilter",
+ Parameters={
+ "StoreSupplementaryCalculations":[
+ "Analysis",
+ "APosterioriCovariance",
+ ],
+ },
+ )
+#
+XaStep, VaStep = 0., 1.
+for i in range(1,len(Yobs)):
+ case.setBackground (Vector = "%s"%float(XaStep))
+ case.setBackgroundError (ScalarSparseMatrix = "%s"%float(VaStep))
+ case.setObservation (Vector = Yobs[i])
+ case.execute( nextStep = True )
+ XaStep = case.get("Analysis")[-1]
+ VaStep = case.get("APosterioriCovariance")[-1]
+#
+Xa = case.get("Analysis")
+Pa = case.get("APosterioriCovariance")
+#
+print("")
+print(" Variance a posteriori finale :",Pa[-1])
+print("")
--- /dev/null
+Le filtre de Kalman peut aussi être utilisé pour une **analyse courante des
+observations d'un modèle dynamique donné**. Dans ce cas, l'analyse est conduite
+de manière itérative, lors de l'arrivée de chaque observation.
+
+L'exemple suivant porte sur le même système dynamique simple issu de la
+référence [Welch06]_. La différence essentielle consiste à effectuer
+l'exécution d'une étape de Kalman à l'arrivée de chaque observation fournie
+itérativement. Le mot-clé "*nextStep*", inclut dans l'ordre d'exécution, permet
+de ne pas stocker l'ébauche en double de l'analyse précédente.
+