gtsam
Loading...
Searching...
No Matches
gtsam::Sampler Class Reference

Detailed Description

Sampling structure that keeps internal random number generators for diagonal distributions specified by NoiseModel.

basic functionality

Vector sample () const
 sample from distribution
template<typename T>
T perturb (const T &value) const
 Perturb a value by sampling in its tangent space and applying retract.
static Vector sampleDiagonal (const Vector &sigmas, std::mt19937_64 *rng)
 sample with given random number generator

Public Member Functions

constructors
 Sampler (const noiseModel::Diagonal::shared_ptr &model, uint_fast64_t seed=42u)
 Create a sampler for the distribution specified by a diagonal NoiseModel with a manually specified seed.
 Sampler (const noiseModel::Diagonal::shared_ptr &model, std::mt19937_64 &rng)
 Create a sampler that draws from a caller-supplied RNG (stateful).
 Sampler (const Vector &sigmas, uint_fast64_t seed=42u)
 Create a sampler for a distribution specified by a vector of sigmas directly.
 Sampler (const Vector &sigmas, std::mt19937_64 &rng)
 Create a sampler for sigmas that draws from a caller-supplied RNG (stateful).
access functions
size_t dim () const
Vector sigmas () const
const noiseModel::Diagonal::shared_ptr & model () const

Public Types

typedef std::shared_ptr< Sampler > shared_ptr

Protected Member Functions

Vector sampleDiagonal (const Vector &sigmas) const
 Given sigmas for a diagonal model, returns a sample.

Protected Attributes

noiseModel::Diagonal::shared_ptr model_
 noiseModel created at generation
std::mt19937_64 generator_
 generator
std::mt19937_64 * externalGenerator_ = nullptr
 Non-owning optional external generator. If non-null, sampling uses this.

Constructor & Destructor Documentation

◆ Sampler() [1/4]

gtsam::Sampler::Sampler ( const noiseModel::Diagonal::shared_ptr & model,
uint_fast64_t seed = 42u )
explicit

Create a sampler for the distribution specified by a diagonal NoiseModel with a manually specified seed.

This constructor is convenient for deterministic, throw-away sampling. If you need stateful sampling across calls or across multiple Sampler instances, prefer the RNG-based constructor and manage the RNG yourself.

NOTE: do not use zero as a seed, it will break the generator.

◆ Sampler() [2/4]

gtsam::Sampler::Sampler ( const noiseModel::Diagonal::shared_ptr & model,
std::mt19937_64 & rng )
explicit

Create a sampler that draws from a caller-supplied RNG (stateful).

The RNG is non-owning and must outlive this Sampler.

◆ Sampler() [3/4]

gtsam::Sampler::Sampler ( const Vector & sigmas,
uint_fast64_t seed = 42u )
explicit

Create a sampler for a distribution specified by a vector of sigmas directly.

This constructor is convenient for deterministic, throw-away sampling. If you need stateful sampling across calls or across multiple Sampler instances, prefer the RNG-based constructor and manage the RNG yourself.

NOTE: do not use zero as a seed, it will break the generator.

◆ Sampler() [4/4]

gtsam::Sampler::Sampler ( const Vector & sigmas,
std::mt19937_64 & rng )
explicit

Create a sampler for sigmas that draws from a caller-supplied RNG (stateful).

The RNG is non-owning and must outlive this Sampler.

Member Function Documentation

◆ perturb()

template<typename T>
T gtsam::Sampler::perturb ( const T & value) const
inline

Perturb a value by sampling in its tangent space and applying retract.

The supplied noise model must match the dimensionality expected by T.

◆ sampleDiagonal()

Vector gtsam::Sampler::sampleDiagonal ( const Vector & sigmas) const
protected

Given sigmas for a diagonal model, returns a sample.

Uses external RNG if available.


The documentation for this class was generated from the following files:
  • /tmp/gtsam-4.3.0-doxygen.rsXPUS/source/gtsam/linear/Sampler.h
  • /tmp/gtsam-4.3.0-doxygen.rsXPUS/source/gtsam/linear/Sampler.cpp