Gazebo Math

API Reference

8.0.0
GaussMarkovProcess Class Reference

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

#include <gz/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().
 
double Mu () const
 Get the mu ( \(\mu\)) value.
 
void Reset ()
 Reset the process. This will set the current process value to the start value.
 
void Set (double _start, double _theta, double _mu, double _sigma)
 Set the process parameters. This will also call Reset().
 
double Sigma () const
 Get the sigma ( \(\sigma\)) value.
 
double Start () const
 Get the start value.
 
double Theta () const
 Get the theta ( \(\theta\)) value.
 
double Update (const clock::duration &_dt)
 Update the process and get the new value.
 
double Update (double _dt)
 
double Value () const
 Get the current process value.
 

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.
gz::math::GaussMarkovProcess gmp(20.2, 0.1, 0, 0.5);
std::chrono::steady_clock::duration dt = std::chrono::milliseconds(100);
// 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;
}

Constructor & Destructor Documentation

◆ GaussMarkovProcess() [1/2]

◆ 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]_startThe start value of the process.
[in]_thetaThe theta ( \(\theta\)) parameter. A value of zero will be used if this parameter is negative.
[in]_muThe mu ( \(\mu\)) parameter.
[in]_sigmaThe sigma ( \(\sigma\)) parameter. A value of zero will be used if this parameter is negative.
See also
Update(const clock::duration &)

Member Function Documentation

◆ Mu()

double Mu ( ) const

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

Returns
The mu value.
See also
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]_startThe start value of the process.
[in]_thetaThe theta ( \(\theta\)) parameter.
[in]_muThe mu ( \(\mu\)) parameter.
[in]_sigmaThe sigma ( \(\sigma\)) parameter.
See also
Update(const clock::duration &)

◆ Sigma()

double Sigma ( ) const

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

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

◆ Start()

double Start ( ) const

Get the start value.

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

◆ Theta()

double Theta ( ) const

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

Returns
The theta value.
See also
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

See also: https://en.wikipedia.org/wiki/Ornstein%E2%80%93Uhlenbeck_process

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

Parameters
[in]_dtLength 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: