MIRA
Public Types | Public Member Functions | List of all members
NormalRandomDistribution< D, T > Class Template Reference

Random distribution for drawing samples from univariate or multivariate normal distributions. More...

#include <math/NormalRandomGenerator.h>

Inheritance diagram for NormalRandomDistribution< D, T >:
Inheritance graph
[legend]

Public Types

typedef T input_type
 
typedef Eigen::Matrix< T, D, 1 > result_type
 
typedef detail::NormalRandomDistributionBase< T > Base
 
typedef Eigen::Matrix< T, D, D > VarianceType
 

Public Member Functions

 NormalRandomDistribution ()
 
 NormalRandomDistribution (const Eigen::Matrix< T, D, D > &sigma)
 
bool setSigma (const Eigen::Matrix< T, D, D > &sigma)
 Sets the specified covariance matrix. More...
 
template<typename Engine >
Eigen::Matrix< T, D, 1 > operator() (Engine &eng)
 Draws a sample from the normal distribution. More...
 

Detailed Description

template<int D, typename T = float>
class mira::NormalRandomDistribution< D, T >

Random distribution for drawing samples from univariate or multivariate normal distributions.

This class template models a zero-mean normal distribution of the specified dimension D (univariate if D==1 or multivariate if D>1).

It can be used with any of the boost random number generators:

boost::mt19937 engine;
NormalRandomDistribution<2,float> nrnd(Sigma);
boost::variate_generator<boost::mt19937&, NormalRandomDistribution<2,float>> rnd(engine, nrnd);
// draw a sample:
Eigen::Vector2f sample = rnd();

The above instantiation is simplified by the NormalRandomGenerator.

Member Typedef Documentation

◆ input_type

typedef T input_type

◆ result_type

typedef Eigen::Matrix<T,D,1> result_type

◆ Base

typedef detail::NormalRandomDistributionBase<T> Base

◆ VarianceType

typedef Eigen::Matrix<T,D,D> VarianceType

Constructor & Destructor Documentation

◆ NormalRandomDistribution() [1/2]

◆ NormalRandomDistribution() [2/2]

NormalRandomDistribution ( const Eigen::Matrix< T, D, D > &  sigma)
inline

Member Function Documentation

◆ setSigma()

bool setSigma ( const Eigen::Matrix< T, D, D > &  sigma)
inline

Sets the specified covariance matrix.

The method assumes that the provided matrix is symmetric and uses the lower triangular part of the matrix only. The upper triangular part won't be read. If the matrix is not a positive definite matrix the member mL will not set and the method returns false, and otherwise true.

Internally a cholesky decomposition (LLT) of the covariance matrix is performed.

◆ operator()()

Eigen::Matrix<T,D,1> operator() ( Engine &  eng)
inline

Draws a sample from the normal distribution.


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