Hello Open TURNS team,

Long time without you ;-)!

I try to simulate a 1D non stationary stochastic process whose variance decreases along time. What is the most suitable way to achieve it?

Thanks a lot in advance.

Fabien

Hello Open TURNS team,

Long time without you ;-)!

I try to simulate a 1D non stationary stochastic process whose variance decreases along time. What is the most suitable way to achieve it?

Thanks a lot in advance.

Fabien

Hello @FMangeant, what kind of stochastic process do you want to simulate? In the following, I assume it is a non-stationary Gaussian process.

I think the class you are looking for is UserDefinedCovarianceModel. The doc page contains an example showing how to define your own covariance function.

After this, you can define your GaussianProcess with:

`myProcess = ot.GaussianProcess(myCovarianceModel, myMesh)`

(It is best to reuse the mesh used to create `myCovarianceModel`

.)

You can then obtain one realisation with `myProcess.getRealization()`

or several with `myProcess.getSample(10)`

.

1 Like

OK, I will try to build it with this your advice. My goal is to build a 1D stochastic process with a mean trend being linear and a random part following a gaussian noise whose variance is also decreasing along the x-axis until a minimum value. Hope this is clear enough…

I have tried implementing something along these lines. Perhaps you can modify this script to suit your needs?

```
import numpy as np
import openturns as ot
from openturns.viewer import View
# Define the mesh the Gaussian Process will be discretized on
N = 100
a = 0.1
mesh = ot.RegularGrid(0.0, a, N)
# Create a nonstationary white noise covariance model
def noise(t):
return 0.2 + 40.0 * np.exp(-0.5 * t)
covariance_matrix = ot.CovarianceMatrix(np.diag(noise(mesh.getValues())))
covariance_model = ot.UserDefinedCovarianceModel(mesh, covariance_matrix)
# Define a linear trend
trend_function = ot.SymbolicFunction('t', '-0.5 * t')
trend = ot.TrendTransform(trend_function, mesh)
# Define the Gaussian process
gp = ot.GaussianProcess(trend, covariance_model, mesh)
# View a few realizations of the process
ot.RandomGenerator.SetSeed(123) # for reproducibility
View(gp.getSample(5).drawMarginal(0))
```

Here is the output:

2 Likes