Drake
Drake C++ Documentation
stochastic.h File Reference
#include <memory>
#include <type_traits>
#include <variant>
#include <vector>
#include "drake/common/drake_assert.h"
#include "drake/common/drake_copyable.h"
#include "drake/common/eigen_types.h"
#include "drake/common/name_value.h"
#include "drake/common/random.h"
#include "drake/common/symbolic/expression.h"
Include dependency graph for stochastic.h:
This graph shows which files directly or indirectly include this file:

Classes

class  Distribution
 Base class for a single distribution, to be used with YAML archives. More...
 
class  Deterministic
 A single deterministic value. More...
 
class  Gaussian
 A gaussian distribution with mean and stddev. More...
 
class  Uniform
 A uniform distribution with min inclusive and max exclusive. More...
 
class  UniformDiscrete
 Chooses from among discrete values with equal probability. More...
 
class  DistributionVector
 Base class for a vector of distributions, to be used with YAML archives. More...
 
class  DeterministicVector< Size >
 A single deterministic vector value. More...
 
class  GaussianVector< Size >
 A gaussian distribution with vector mean and vector or scalar stddev. More...
 
class  UniformVector< Size >
 A uniform distribution with vector min inclusive and vector max exclusive. More...
 

Namespaces

 drake
 
 drake::schema
 

Macros

#define DRAKE_DECLARE_TEMPLATE_INSTANTIATIONS_ON_ALL_SIZES(Func)
 

Typedefs

using DistributionVariant = std::variant< double, Deterministic, Gaussian, Uniform, UniformDiscrete >
 Variant over all kinds of distributions. More...
 
template<int Size>
using DistributionVectorVariant = std::variant< drake::Vector< double, Size >, DeterministicVector< Size >, GaussianVector< Size >, UniformVector< Size >, std::conditional_t<(Size==Eigen::Dynamic||Size==1), Deterministic, internal::InvalidVariantSelection< Deterministic > >, std::conditional_t<(Size==Eigen::Dynamic||Size==1), Gaussian, internal::InvalidVariantSelection< Gaussian > >, std::conditional_t<(Size==Eigen::Dynamic||Size==1), Uniform, internal::InvalidVariantSelection< Uniform > >>
 Variant over all kinds of vector distributions. More...
 
using DistributionVectorVariantX = DistributionVectorVariant< Eigen::Dynamic >
 DistributionVectorVariant that permits any vector size dynamically. More...
 

Functions

std::unique_ptr< Distribution > ToDistribution (const DistributionVariant &var)
 Copies the given variant into a Distribution base class. More...
 
double Sample (const DistributionVariant &var, drake::RandomGenerator *generator)
 Like Distribution::Sample, but on a DistributionVariant instead. More...
 
double Mean (const DistributionVariant &var)
 Like Distribution::Mean, but on a DistributionVariant instead. More...
 
drake::symbolic::Expression ToSymbolic (const DistributionVariant &var)
 Like Distribution::ToSymbolic, but on a DistributionVariant instead. More...
 
Eigen::VectorXd Sample (const std::vector< DistributionVariant > &vec, drake::RandomGenerator *generator)
 Like Distribution::Sample, but elementwise over a collection of possibly-heterogenous DistributionVariant instead. More...
 
Eigen::VectorXd Mean (const std::vector< DistributionVariant > &vec)
 Like Distribution::Mean, but elementwise over a collection of possibly-heterogenous DistributionVariant instead. More...
 
drake::VectorX< drake::symbolic::ExpressionToSymbolic (const std::vector< DistributionVariant > &vec)
 Like Distribution::ToSymbolic, but elementwise over a collection of possibly-heterogenous DistributionVariant instead. More...
 
bool IsDeterministic (const DistributionVariant &var)
 Returns true iff var is set to a deterministic value. More...
 
double GetDeterministicValue (const DistributionVariant &var)
 If var is deterministic, retrieves its value. More...
 
template<int Size>
std::unique_ptr< DistributionVector > ToDistributionVector (const DistributionVectorVariant< Size > &vec)
 Copies the given variant into a DistributionVector base class. More...
 
template<int Size>
bool IsDeterministic (const DistributionVectorVariant< Size > &vec)
 Returns true iff all of vec's elements are set to a deterministic value. More...
 
template<int Size>
Eigen::VectorXd GetDeterministicValue (const DistributionVectorVariant< Size > &vec)
 If vec is deterministic, retrieves its value. More...
 

Macro Definition Documentation

◆ DRAKE_DECLARE_TEMPLATE_INSTANTIATIONS_ON_ALL_SIZES

#define DRAKE_DECLARE_TEMPLATE_INSTANTIATIONS_ON_ALL_SIZES (   Func)
Value:
extern template Func(const DistributionVectorVariantX&); \
extern template Func(const DistributionVectorVariant<1>&); \
extern template Func(const DistributionVectorVariant<2>&); \
extern template Func(const DistributionVectorVariant<3>&); \
extern template Func(const DistributionVectorVariant<4>&); \
extern template Func(const DistributionVectorVariant<5>&); \
extern template Func(const DistributionVectorVariant<6>&);
DistributionVectorVariant< Eigen::Dynamic > DistributionVectorVariantX
DistributionVectorVariant that permits any vector size dynamically.
Definition: stochastic.h:489