.. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_probabilistic_modeling_stochastic_processes_plot_regular_grid_creation.py: Creation of a regular grid ========================== In this example we will demonstrate how to create a regular grid. Note that a regular grid is a particular mesh of :math:`\mathcal{D}=[0,T] \in \mathbb{R}`. Here we will assume it represents the time :math:`t` as it is often the case, but it can represent any physical quantity. A regular time grid is a regular discretization of the interval :math:`[0, T] \in \mathbb{R}` into :math:`N` points, noted :math:`(t_0, \dots, t_{N-1})`. The time grid can be defined using :math:`(t_{Min}, \Delta t, N)` where :math:`N` is the number of points in the time grid. :math:`\Delta t` the time step between two consecutive instants and :math:`t_0 = t_{Min}`. Then, :math:`t_k = t_{Min} + k \Delta t` and :math:`t_{Max} = t_{Min} + (N-1) \Delta t`. Consider :math:`X: \Omega \times \mathcal{D} \rightarrow \mathbb{R}^d` a multivariate stochastic process of dimension :math:`d`, where :math:`n=1`, :math:`\mathcal{D}=[0,T]` and :math:`t\in \mathcal{D}` is interpreted as a time stamp. Then the mesh associated to the process :math:`X` is a (regular) time grid. .. code-block:: default from __future__ import print_function import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt import math as m ot.Log.Show(ot.Log.NONE) .. code-block:: default tMin = 0. tStep = 0.1 n = 10 # Create the grid time_grid = ot.RegularGrid(tMin, tStep, n) Get the first and the last instants, the step and the number of points .. code-block:: default start = time_grid.getStart() step = time_grid.getStep() grid_size = time_grid.getN() end = time_grid.getEnd() print('start=', start, 'step=', step, 'grid_size=', grid_size, 'end=', end) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none start= 0.0 step= 0.1 grid_size= 10 end= 1.0 draw the grid .. code-block:: default time_grid.setName('time') graph = time_grid.draw() view = viewer.View(graph) plt.show() .. image:: /auto_probabilistic_modeling/stochastic_processes/images/sphx_glr_plot_regular_grid_creation_001.png :alt: Mesh time :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.069 seconds) .. _sphx_glr_download_auto_probabilistic_modeling_stochastic_processes_plot_regular_grid_creation.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_regular_grid_creation.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_regular_grid_creation.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_