The product of independent densities, each on its own coordinates of a space.
More...
|
template<typename... Placed>
requires (sizeof...(Placed) == sizeof...(Factors_) && (std::is_same_v<typename internal::PlacedFactor<Placed>::template TypeIn
<Space_>, Factors_> && ...)) |
| | Product (Space_ space, Placed... placed) |
| | The product of the factors placed, made by on() or onEach(), in space.
|
|
template<typename... Placed> |
| | Product (Space_ space, Factors< Placed... > const &factors) |
| | The product of factors placed in space (see Factors).
|
| Index | valueDimension () const |
| Index | differenceDimension () const |
| Space_ const & | space () const |
| template<std::size_t K> |
| FactorType< K > const & | factor () const |
| template<std::size_t K> |
| auto const & | indices () const |
|
template<typename Fn> |
| void | forEachFactor (Fn &&fn) const |
| | Calls fn(density, indices) for each factor in order, with its density (a view, for parameters) and the coordinates it covers.
|
| template<typename Derived> |
| Scalar | logDensity (Eigen::MatrixBase< Derived > const &x) const |
| template<typename Derived> |
| Scalar | density (Eigen::MatrixBase< Derived > const &x) const |
| auto | moments () const -> std::conditional_t< MomentsMayFail, std::expected< MomentsType, MomentsError >, MomentsType > |
| template<typename Path> |
| decltype(auto) | marginal () const & |
|
template<typename Path> |
| void | marginal () const &&=delete |
| | A marginal of a temporary would outlive it.
|
| template<typename GivenPath, typename Derived> |
| auto | conditional (Eigen::MatrixBase< Derived > const &values) const |
template<Space Space_, RealScalar Scalar_, ProductFactor... Factors_>
class Emrys::Product< Space_, Scalar_, Factors_ >
The product of independent densities, each on its own coordinates of a space.
Represents \( p(x) = \prod_k p_k(x_{S_k}) \), where the index sets \( S_k \) partition the coordinates: the joint density of independent blocks. A prior that is Gaussian in position, uniform in heading, and Gamma in speed is one product:
static std::expected< Gamma, GammaError > create(Space_ space, Shape const &shape, Scale const &scale)
Definition Gamma.h:158
The product of independent densities, each on its own coordinates of a space.
Definition Product.h:772
auto on(Model const &model, Renames const &...)
Definition Placement.h:1067
Each factor's space must be the space of the block it covers: a factor placed by on<Path>() is built in that block's space, a tag derived from it, or with both linear. Sampling fills each factor's rows; log-densities add.
A factor is a density or parameters (see ProductFactor), held by value. The product checks parameters with toDensity() when it is built, and asserts that this succeeds; call their toDensity() first to handle a failure. A factor that is a view, such as a Gaussian, checks its parameters, which then must not change while the product is read, so prefer passing the parameters.
marginal<Path>() and conditional<GivenPath>() work on the factors' blocks, matched by the factors' space types:
- a path through a factor's space type, or to a block inside it, is that factor's own marginal or conditional, and the other factors are unchanged;
- a path to a block made of whole factors selects those factors, or drops them when given. A marginal or conditional with one factor left returns that factor alone. Marginals return parameters or values, never views of this product. A conditional that may fail, such as a Student-t's or a Gaussian's that must factorize, returns a std::expected.
- Template Parameters
-
| Space_ | space of the whole vector (see Spaces) |
| Scalar_ | scalar type, shared by every factor |
| Factors_ | the factors' types, in order |
- See also
- on(), drawSamples(Product const &, Eigen::Index, G &)
template<Space Space_, RealScalar Scalar_, ProductFactor... Factors_>
template<typename... Placed>
requires (sizeof...(Placed) == sizeof...(Factors_) && (std::is_same_v<typename internal::PlacedFactor<Placed>::template TypeIn
<Space_>, Factors_> && ...))
| Emrys::Product< Space_, Scalar_, Factors_ >::Product |
( |
Space_ | space, |
|
|
Placed... | placed ) |
|
inlineexplicit |
The product of the factors placed, made by on() or onEach(), in space.
Their indices must partition the space, and each factor's space must be that of the block it covers.