# Ignition Math

## API Reference

6.10.0
GaussMarkovProcess Class Reference

Implementation of a stationary gauss-markov process, also known as a Ornstein Ulenbeck process. More...

#include <ignition/math/GaussMarkovProcess.hh>

## Public Member Functions

GaussMarkovProcess ()

GaussMarkovProcess (double _start, double _theta, double _mu, double _sigma)
Create a process with the provided process parameters. This will also call Set(), and in turn Reset(). More...

~GaussMarkovProcess ()
Destructor. More...

double Mu () const
Get the mu ( $$\mu$$) value. More...

void Reset ()
Reset the process. This will set the current process value to the start value. More...

void Set (double _start, double _theta, double _mu, double _sigma)
Set the process parameters. This will also call Reset(). More...

double Sigma () const
Get the sigma ( $$\sigma$$) value. More...

double Start () const
Get the start value. More...

double Theta () const
Get the theta ( $$\theta$$) value. More...

double Update (const clock::duration &_dt)
Update the process and get the new value. More...

double Update (double _dt)

double Value () const
Get the current process value. More...

## Detailed Description

Implementation of a stationary gauss-markov process, also known as a Ornstein Ulenbeck process.

See the Update(const clock::duration &) for details on the forumla used to update the process.

## Example usage

#include <iostream>
// You can plot the data generated by this program by following these
// steps.
//
// 1. Run this program and save the output to a file:
// ./gauss_markov_process > plot.data
//
// 2. Use gnuplot to create a plot:
// gnuplot -e 'set terminal jpeg; plot "plot.data" with lines' > out.jpg
int main(int argc, char **argv)
{
// Create the process with:
// * Start value of 20.2
// * Theta (rate at which the process should approach the mean) of 0.1
// * Mu (mean value) 0.
// * Sigma (volatility) of 0.5.
ignition::math::GaussMarkovProcess gmp(20.2, 0.1, 0, 0.5);
// This process should decrease toward the mean value of 0.
// With noise of 0.5, the process will walk a bit.
for (int i = 0; i < 1000; ++i)
{
double value = gmp.Update(dt);
std::cout << value << std::endl;
}
return 0;
}

## ◆ GaussMarkovProcess() [1/2]

 GaussMarkovProcess ( )

## ◆ GaussMarkovProcess() [2/2]

 GaussMarkovProcess ( double _start, double _theta, double _mu, double _sigma )

Create a process with the provided process parameters. This will also call Set(), and in turn Reset().

Parameters
 [in] _start The start value of the process. [in] _theta The theta ( $$\theta$$) parameter. A value of zero will be used if this parameter is negative. [in] _mu The mu ( $$\mu$$) parameter. [in] _sigma The sigma ( $$\sigma$$) parameter. A value of zero will be used if this parameter is negative.
Update(const clock::duration &)

## ◆ ~GaussMarkovProcess()

 ~GaussMarkovProcess ( )

Destructor.

## ◆ Mu()

 double Mu ( ) const

Get the mu ( $$\mu$$) value.

Returns
The mu value.
Set(double, double, double, double)

## ◆ Reset()

 void Reset ( )

Reset the process. This will set the current process value to the start value.

## ◆ Set()

 void Set ( double _start, double _theta, double _mu, double _sigma )

Set the process parameters. This will also call Reset().

Parameters
 [in] _start The start value of the process. [in] _theta The theta ( $$\theta$$) parameter. [in] _mu The mu ( $$\mu$$) parameter. [in] _sigma The sigma ( $$\sigma$$) parameter.
Update(const clock::duration &)

## ◆ Sigma()

 double Sigma ( ) const

Get the sigma ( $$\sigma$$) value.

Returns
The sigma value.
Set(double, double, double, double)

## ◆ Start()

 double Start ( ) const

Get the start value.

Returns
The start value.
Set(double, double, double, double)

## ◆ Theta()

 double Theta ( ) const

Get the theta ( $$\theta$$) value.

Returns
The theta value.
Set(double, double, double, double)

## ◆ Update() [1/2]

 double Update ( const clock::duration & _dt )

Update the process and get the new value.

The following equation is computed:

$$x_{t+1} += \theta * (\mu - x_t) * dt + \sigma * dW_t$$

where

• $$\theta, \mu, \sigma$$ are parameters specified by the user. In order, the parameters are theta, mu, and sigma. Theta and sigma must be greater than or equal to zero. You can think of mu as representing the mean or equilibrium value, sigma as the degree of volatility, and theta as the rate by which changes dissipate and revert towards the mean.
• $$dt$$ is the time step in seconds.
• $$dW_t$$ is a random number drawm from a normal distribution with mean of zero and variance of 1.
• $$x_t$$ is the current value of the Gauss-Markov process
• $$x_{t+1}$$ is the new value of the Gauss-Markvov process

This implementation include a drift parameter, mu. In financial mathematics, this is known as a Vasicek model.

Parameters
 [in] _dt Length of the timestep after which a new sample should be taken.
Returns
The new value of this process.

## ◆ Update() [2/2]

 double Update ( double _dt )

## ◆ Value()

 double Value ( ) const

Get the current process value.

Returns
The value of the process.

The documentation for this class was generated from the following file: