.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/tracking/plotSimulatedTrajectoryDWPA.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_tracking_plotSimulatedTrajectoryDWPA.py: Sampling from a Discrete Wiener Process Acceleration Model ========================================================== The code below samples from a Discrete Wiener Process Acceleration (DWPA) model. .. GENERATED FROM PYTHON SOURCE LINES 12-14 Import packages ~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 14-22 .. code-block:: Python import numpy as np import plotly.graph_objs as go import lds.tracking.utils import lds.simulation .. GENERATED FROM PYTHON SOURCE LINES 23-25 Set initial conditions and parameters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 25-39 .. code-block:: Python pos_x0 = 0.0 pos_y0 = 0.0 vel_x0 = 0.0 vel_y0 = 0.0 ace_x0 = 0.0 ace_y0 = 0.0 dt = 1e-3 num_pos = 1000 sigma_a = 1.0 sigma_x = 1.0 sigma_y = 1.0 sqrt_diag_V0_value = 1e-03 .. GENERATED FROM PYTHON SOURCE LINES 40-42 Set LDS parameters ~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 42-50 .. code-block:: Python B, Q, Z, R, Qe = lds.tracking.utils.getLDSmatricesForTracking( dt=dt, sigma_a=sigma_a, sigma_x=sigma_x, sigma_y=sigma_y) R = np.diag([sigma_x**2, sigma_y**2]) m0 = np.array([pos_x0, vel_x0, ace_x0, pos_y0, vel_y0, ace_y0], dtype=np.double) V0 = np.diag(np.ones(len(m0))*sqrt_diag_V0_value**2) .. GENERATED FROM PYTHON SOURCE LINES 51-55 Sample from the LDS ~~~~~~~~~~~~~~~~~~~ View source code of `lds.simulation.simulateLDS `_ .. GENERATED FROM PYTHON SOURCE LINES 55-59 .. code-block:: Python x0, x, y = lds.simulation.simulateLDS(N=num_pos, B=B, Q=Q, Z=Z, R=R, m0=m0, V0=V0) .. GENERATED FROM PYTHON SOURCE LINES 60-62 Plot state positions and measurements ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 62-77 .. code-block:: Python fig = go.Figure() trace_x = go.Scatter(x=x[0, :], y=x[3, :], mode="markers", showlegend=True, name="state position") trace_y = go.Scatter(x=y[0, :], y=y[1, :], mode="markers", showlegend=True, name="measured position", opacity=0.3) trace_start = go.Scatter(x=[x0[0]], y=[x0[3]], mode="markers", text="initial state position", marker={"size": 7}, showlegend=False) fig.add_trace(trace_x) fig.add_trace(trace_y) fig.add_trace(trace_start) # fig_filename_pattern = "../../figures/simulated_pos.{:s}" # fig.write_image(fig_filename_pattern.format("png")) # fig.write_html(fig_filename_pattern.format("html")) fig .. raw:: html


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.014 seconds) .. _sphx_glr_download_auto_examples_tracking_plotSimulatedTrajectoryDWPA.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/joacorapela/lds_python/gh-pages?filepath=notebooks/auto_examples/tracking/plotSimulatedTrajectoryDWPA.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plotSimulatedTrajectoryDWPA.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plotSimulatedTrajectoryDWPA.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plotSimulatedTrajectoryDWPA.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_