|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Mixture of Probabilistic Principal Component Analyzers (MPPCA). More...
#include <mppca.h>
Public Member Functions | |
| void | set (const VectorX< T > &pi, const MatrixX< T > &mmu, momentum::span< const MatrixX< T > > W, const VectorX< T > &sigma2) |
| Initializes the model from raw mixture parameters and precomputes Cinv, L, and Rpre for fast log-likelihood evaluation. | |
| template<typename T2> | |
| MppcaT< T2 > | cast () const |
| Returns a copy of this model with all numeric data converted to scalar type T2. | |
| bool | isApprox (const MppcaT< T > &mppcaT) const |
| Returns true if every member matches mppcaT exactly (d, p, names) or approximately (mu, Cinv, L, Rpre) using Eigen's isApprox default tolerance. | |
Public Attributes | |
| size_t | d = 0 |
| Dimensionality of the data space x. | |
| size_t | p = 0 |
| Number of mixture components. | |
| std::vector< std::string > | names |
| Optional human-readable names for each of the d data dimensions. | |
| Eigen::MatrixX< T > | mu |
| Per-component mean vectors stored as a p x d matrix; row c is mu_c. | |
| std::vector< Eigen::MatrixX< T > > | Cinv |
| Per-component inverse covariance matrices C_c^{-1} of size d x d. | |
| std::vector< Eigen::MatrixX< T > > | L |
| Per-component lower-triangular factors derived from the Cholesky-like decomposition of C_c (used as a whitening transform when sampling or evaluating the Mahalanobis term efficiently). | |
| Eigen::VectorX< T > | Rpre |
| Per-component constant term of the log-likelihood: Rpre(c) = log(pi_c) - 0.5 * log|C_c| - (d/2) * log(2*pi). | |
Mixture of Probabilistic Principal Component Analyzers (MPPCA).
Each component models the data as x = W_c z + mu_c + epsilon, where z is a low-dimensional latent vector and epsilon ~ N(0, sigma_c^2 I) is isotropic noise. The full mixture density is p(x) = sum_c pi_c N(x | mu_c, C_c) with C_c = W_c W_c^T + sigma_c^2 I.
After set(), the model stores precomputed quantities so that the per-component log-likelihood of a sample x can be evaluated as Rpre(c) - 0.5 * (x - mu.row(c))^T * Cinv[c] * (x - mu.row(c)).
Based on: http://www.miketipping.com/papers/met-mppca.pdf
| T | Scalar type (float or double). |
|
nodiscard |
Returns a copy of this model with all numeric data converted to scalar type T2.
Names and dimensions are copied unchanged.
| T2 | Target scalar type. |
Definition at line 113 of file mppca.cpp.
References momentum::cast(), momentum::castMatrices(), Cinv, d, L, mu, names, p, and Rpre.
|
nodiscard |
Returns true if every member matches mppcaT exactly (d, p, names) or approximately (mu, Cinv, L, Rpre) using Eigen's isApprox default tolerance.
| [in] | mppcaT | Model to compare with. |
Definition at line 128 of file mppca.cpp.
References Cinv, d, momentum::isApprox(), L, mu, names, p, and Rpre.
| void momentum::MppcaT< T >::set | ( | const VectorX< T > & | pi, |
| const MatrixX< T > & | mmu, | ||
| momentum::span< const MatrixX< T > > | W, | ||
| const VectorX< T > & | sigma2 ) |
Initializes the model from raw mixture parameters and precomputes Cinv, L, and Rpre for fast log-likelihood evaluation.
| [in] | pi | Mixture weights, length p. Must sum to 1 and be > 0. |
| [in] | mmu | Per-component means as a p x d matrix (row c is mu_c). |
| [in] | W | Per-component factor-loading matrices W_c; expected to be of size d x q_c where q_c < d is the latent dimension. Length p. |
| [in] | sigma2 | Per-component isotropic noise variances sigma_c^2, length p. Must be strictly positive. |
Definition at line 17 of file mppca.cpp.
References Cinv, d, L, MT_THROW_IF, mu, names, p, Rpre, and momentum::twopi().
| std::vector<Eigen::MatrixX<T> > momentum::MppcaT< T >::Cinv |
Per-component inverse covariance matrices C_c^{-1} of size d x d.
Definition at line 45 of file mppca.h.
Referenced by cast(), isApprox(), momentum::saveMppca(), and set().
| size_t momentum::MppcaT< T >::d = 0 |
Dimensionality of the data space x.
Definition at line 31 of file mppca.h.
Referenced by cast(), isApprox(), momentum::saveMppca(), and set().
| std::vector<Eigen::MatrixX<T> > momentum::MppcaT< T >::L |
| Eigen::MatrixX<T> momentum::MppcaT< T >::mu |
Per-component mean vectors stored as a p x d matrix; row c is mu_c.
Definition at line 41 of file mppca.h.
Referenced by cast(), isApprox(), momentum::saveMppca(), and set().
| std::vector<std::string> momentum::MppcaT< T >::names |
Optional human-readable names for each of the d data dimensions.
set() resizes this to d empty strings; callers may overwrite entries.
Definition at line 38 of file mppca.h.
Referenced by cast(), isApprox(), momentum::saveMppca(), and set().
| size_t momentum::MppcaT< T >::p = 0 |
Number of mixture components.
Definition at line 34 of file mppca.h.
Referenced by cast(), isApprox(), momentum::saveMppca(), and set().
| Eigen::VectorX<T> momentum::MppcaT< T >::Rpre |
Per-component constant term of the log-likelihood: Rpre(c) = log(pi_c) - 0.5 * log|C_c| - (d/2) * log(2*pi).
Add the -0.5 * Mahalanobis term to obtain the log-density of x under component c. Length is p after set().
Definition at line 57 of file mppca.h.
Referenced by cast(), isApprox(), momentum::saveMppca(), and set().