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 \mathcal{D}=[0,T] \in \mathbb{R}.

Here we will assume it represents the time 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 [0, T] \in \mathbb{R} into N points, noted (t_0, \dots, t_{N-1}).

The time grid can be defined using (t_{Min}, \Delta t, N) where N is the number of points in the time grid. \Delta t the time step between two consecutive instants and t_0 = t_{Min}. Then, t_k = t_{Min} + k \Delta t and t_{Max} = t_{Min} + (N-1) \Delta t.

Consider X: \Omega \times \mathcal{D} \rightarrow \mathbb{R}^d a multivariate stochastic process of dimension d, where n=1, \mathcal{D}=[0,T] and t\in \mathcal{D} is interpreted as a time stamp. Then the mesh associated to the process X is a (regular) time grid.

[1]:
from __future__ import print_function
import openturns as ot
import math as m
[2]:
tMin = 0.
tStep = 0.1
n = 10

# Create the grid
time_grid = ot.RegularGrid(tMin, tStep, n)
[3]:
# Get the first and the last instants,
# the step and the number of points
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)
start= 0.0 step= 0.1 grid_size= 10 end= 1.0
[13]:
# draw the grid
time_grid.setName('time')
time_grid.draw()
[13]:
../../_images/examples_probabilistic_modeling_regular_grid_creation_5_0.png