OpenKalman
Public Member Functions | Public Attributes | Protected Types | Static Protected Attributes | List of all members
OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine > Struct Template Reference

A Gaussian distribution, defined in terms of a Mean and a Covariance. More...

#include <forward-class-declarations.hpp>

Collaboration diagram for OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine >:
Collaboration graph
[legend]

Public Member Functions

template<typename Arg , std::enable_if_t< gaussian_distribution< Arg > and not std::is_base_of_v< GaussianDistribution, std::decay_t< Arg >> and compares_with< typename DistributionTraits< Arg >::StaticDescriptor, StaticDescriptor >, int > = 0>
 GaussianDistribution (Arg &&arg)
 Construct from related distribution.
 
 GaussianDistribution (Mean &&mean, Covariance &&cov)
 Construct from an rvalue of a mean and a covariance.
 
template<typename M , std::enable_if_t< typed_matrix< M > and vector< M > and has_untyped_index< M, 1 > and compares_with< vector_space_descriptor_of_t< M, 0 >, StaticDescriptor >, int > = 0>
 GaussianDistribution (M &&mean, Covariance &&cov)
 Construct from a typed_matrix and an rvalue of a covariance.
 
template<typename M , std::enable_if_t< typed_matrix_nestable< M > and vector< M > and(index_dimension_of< M, 0 >::value==dim), int > = 0>
 GaussianDistribution (M &&mean, Covariance &&cov)
 Construct from a typed_matrix_nestable and an rvalue of a covariance.
 
template<typename Cov , std::enable_if_t<(covariance< Cov > or(typed_matrix< Cov > and square_shaped< Cov >)) and compares_with< vector_space_descriptor_of_t< Cov, 0 >, StaticDescriptor >, int > = 0>
 GaussianDistribution (Mean &&mean, Cov &&cov)
 Construct from an rvalue of a mean and a covariance, typed_matrix, or covariance_nestable.
 
template<typename Cov , std::enable_if_t< covariance_nestable< Cov > and(index_dimension_of< Cov, 0 >::value==dim), int > = 0>
 GaussianDistribution (Mean &&mean, Cov &&cov)
 
template<typename M , typename Cov , std::enable_if_t< typed_matrix< M > and vector< M > and has_untyped_index< M, 1 > and compares_with< vector_space_descriptor_of_t< M, 0 >, StaticDescriptor > and(covariance< Cov > or typed_matrix< Cov >) and compares_with< vector_space_descriptor_of_t< Cov, 0 >, StaticDescriptor >, int > = 0>
 GaussianDistribution (M &&mean, Cov &&cov)
 Construct from matrices representing a mean and a covariance. More...
 
template<typename M , typename Cov , std::enable_if_t< typed_matrix< M > and vector< M > and has_untyped_index< M, 1 > and compares_with< vector_space_descriptor_of_t< M, 0 >, StaticDescriptor > and covariance_nestable< Cov > and(index_dimension_of< Cov, 0 >::value==dim), int > = 0>
 GaussianDistribution (M &&mean, Cov &&cov)
 Construct from matrices representing a mean and a covariance. More...
 
template<typename M , typename Cov , std::enable_if_t< typed_matrix_nestable< M > and vector< M > and(index_dimension_of< M, 0 >::value==dim) and(covariance< Cov > or typed_matrix< Cov >) and compares_with< vector_space_descriptor_of_t< Cov, 0 >, StaticDescriptor >, int > = 0>
 GaussianDistribution (M &&mean, Cov &&cov)
 Construct from matrices representing a mean and a covariance. More...
 
template<typename M , typename Cov , std::enable_if_t< typed_matrix_nestable< M > and vector< M > and(index_dimension_of< M, 0 >::value==dim) and covariance_nestable< Cov > and(index_dimension_of< Cov, 0 >::value==dim), int > = 0>
 GaussianDistribution (M &&mean, Cov &&cov)
 Construct from matrices representing a mean and a covariance. More...
 
template<typename Cov , std::enable_if_t<(covariance< Cov > or(typed_matrix< Cov > and square_shaped< Cov >)) and compares_with< vector_space_descriptor_of_t< Cov, 0 >, StaticDescriptor >, int > = 0>
 GaussianDistribution (Cov &&cov)
 Construct with only a covariance or square typed_matrix (mean is set to zero).
 
template<typename Cov , std::enable_if_t< covariance_nestable< Cov > and(index_dimension_of< Cov, 0 >::value==dim), int > = 0>
 GaussianDistribution (Cov &&cov)
 Construct using only a covariance_nestable (the mean is set to zero).
 
template<typename Arg , std::enable_if_t< gaussian_distribution< Arg > and compares_with< typename DistributionTraits< Arg >::StaticDescriptor, StaticDescriptor >, int > = 0>
GaussianDistributionoperator= (Arg &&arg)
 Assign from another compatible distribution.
 
auto & operator+= (const GaussianDistribution &arg)
 
auto & operator-= (const GaussianDistribution &arg)
 
template<typename S , std::enable_if_t< std::is_convertible_v< S, const Scalar >, int > = 0>
auto & operator*= (const S scale)
 
template<typename S , std::enable_if_t< std::is_convertible_v< S, const Scalar >, int > = 0>
auto & operator/= (const S scale)
 
auto operator() () const
 Generate a random value from the distribution. More...
 
template<typename... Z, std::enable_if_t<(sizeof...(Z) > 0>
Scalar log_likelihood (const Z &...z) const
 Log-likelihood function for a set of i.i.d. More...
 
Scalar entropy () const
 Entropy of the distribution, in bits.
 

Public Attributes

Mean mu
 The mean of the distribution.
 
Covariance sigma
 The Covariance matrix of the distribution.
 

Protected Types

using Mean = Mean< StaticDescriptor, MeanNestedMatrix >
 
using Covariance = Covariance< StaticDescriptor, CovarianceNestedMatrix >
 
using Scalar = scalar_type_of_t< Mean >
 

Static Protected Attributes

static constexpr auto dim = coordinates::dimension_of_v<StaticDescriptor>
 

Detailed Description

template<typename StaticDescriptor, typename MeanNestedMatrix, typename CovarianceNestedMatrix, typename random_number_engine>
struct OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine >

A Gaussian distribution, defined in terms of a Mean and a Covariance.

Template Parameters
DescriptorCoefficient types.
MeanNestedMatrixThe underlying native matrix for the Mean.
CovarianceNestedMatrixThe underlying native matrix (triangular or self-adjoint) for the Covariance.
random_number_engineA random number engine compatible with the c++ standard library (e.g., std::mt19937).
Todo:
Change to std::mt19937_64 ?

Constructor & Destructor Documentation

◆ GaussianDistribution() [1/4]

template<typename StaticDescriptor, typename MeanNestedMatrix, typename CovarianceNestedMatrix, typename random_number_engine>
template<typename M , typename Cov , std::enable_if_t< typed_matrix< M > and vector< M > and has_untyped_index< M, 1 > and compares_with< vector_space_descriptor_of_t< M, 0 >, StaticDescriptor > and(covariance< Cov > or typed_matrix< Cov >) and compares_with< vector_space_descriptor_of_t< Cov, 0 >, StaticDescriptor >, int > = 0>
OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine >::GaussianDistribution ( M &&  mean,
Cov &&  cov 
)
inline

Construct from matrices representing a mean and a covariance.

Template Parameters
MA typed_matrix.
CovA covariance or square typed_matrix.

◆ GaussianDistribution() [2/4]

template<typename StaticDescriptor, typename MeanNestedMatrix, typename CovarianceNestedMatrix, typename random_number_engine>
template<typename M , typename Cov , std::enable_if_t< typed_matrix< M > and vector< M > and has_untyped_index< M, 1 > and compares_with< vector_space_descriptor_of_t< M, 0 >, StaticDescriptor > and covariance_nestable< Cov > and(index_dimension_of< Cov, 0 >::value==dim), int > = 0>
OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine >::GaussianDistribution ( M &&  mean,
Cov &&  cov 
)
inline

Construct from matrices representing a mean and a covariance.

Template Parameters
MA typed_matrix.
CovA covariance_nestable.

◆ GaussianDistribution() [3/4]

template<typename StaticDescriptor, typename MeanNestedMatrix, typename CovarianceNestedMatrix, typename random_number_engine>
template<typename M , typename Cov , std::enable_if_t< typed_matrix_nestable< M > and vector< M > and(index_dimension_of< M, 0 >::value==dim) and(covariance< Cov > or typed_matrix< Cov >) and compares_with< vector_space_descriptor_of_t< Cov, 0 >, StaticDescriptor >, int > = 0>
OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine >::GaussianDistribution ( M &&  mean,
Cov &&  cov 
)
inline

Construct from matrices representing a mean and a covariance.

Template Parameters
MA typed_matrix_nestable.
CovA covariance or square typed_matrix.

◆ GaussianDistribution() [4/4]

template<typename StaticDescriptor, typename MeanNestedMatrix, typename CovarianceNestedMatrix, typename random_number_engine>
template<typename M , typename Cov , std::enable_if_t< typed_matrix_nestable< M > and vector< M > and(index_dimension_of< M, 0 >::value==dim) and covariance_nestable< Cov > and(index_dimension_of< Cov, 0 >::value==dim), int > = 0>
OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine >::GaussianDistribution ( M &&  mean,
Cov &&  cov 
)
inline

Construct from matrices representing a mean and a covariance.

Template Parameters
MA typed_matrix_nestable.
CovA covariance_nestable.

Member Function Documentation

◆ log_likelihood()

template<typename StaticDescriptor, typename MeanNestedMatrix, typename CovarianceNestedMatrix, typename random_number_engine>
template<typename... Z, std::enable_if_t<(sizeof...(Z) > 0>
Scalar OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine >::log_likelihood ( const Z &...  z) const
inline

Log-likelihood function for a set of i.i.d.

observations z.

Parameters
zOne or more i.i.d. observations in the same multivariate space as the mean of the distribution.

◆ operator()()

template<typename StaticDescriptor, typename MeanNestedMatrix, typename CovarianceNestedMatrix, typename random_number_engine>
auto OpenKalman::GaussianDistribution< StaticDescriptor, MeanNestedMatrix, CovarianceNestedMatrix, random_number_engine >::operator() ( ) const
inline

Generate a random value from the distribution.

Returns
A random, single-column typed matrix with probability based on the distribution

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