| LSSTApplications
    20.0.0
    LSSTDataManagementBasePackage | 
 
 
 
Go to the documentation of this file.
   24 #ifndef LSST_MEAS_MODELFIT_Mixture_h_INCLUDED 
   25 #define LSST_MEAS_MODELFIT_Mixture_h_INCLUDED 
   29 #include "Eigen/Cholesky" 
   30 #include "Eigen/StdVector" 
   31 #include "Eigen/Dense" 
   42 namespace lsst { 
namespace meas { 
namespace modelfit {
 
  102     Eigen::LLT<Matrix> _sigmaLLT;
 
  197     template <
typename Derived>
 
  200         return component.
weight * _evaluate(
z) / component._sqrtDet;
 
  208     template <
typename Derived>
 
  224         ndarray::Array<Scalar const,2,1> 
const & 
x,
 
  225         ndarray::Array<Scalar,1,0> 
const & p
 
  235         ndarray::Array<Scalar const,2,1> 
const & 
x,
 
  236         ndarray::Array<Scalar,2,1> 
const & p
 
  247         ndarray::Array<Scalar const,1,1> 
const & 
x,
 
  248         ndarray::Array<Scalar,1,1> 
const & gradient,
 
  249         ndarray::Array<Scalar,2,1> 
const & hessian
 
  260         Eigen::Matrix<Scalar, Eigen::Dynamic, 1> & 
x,
 
  261         Eigen::Matrix<Scalar, Eigen::Dynamic, 1> & gradient,
 
  262         Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> & hessian
 
  272         Eigen::Matrix<Scalar, Eigen::Dynamic, 1> & 
x,
 
  273         Eigen::Matrix<Scalar, Eigen::Dynamic, 1> & gradient
 
  307         ndarray::Array<Scalar const,2,1> 
const & 
x,
 
  308         ndarray::Array<Scalar const,1,0> 
const & 
w,
 
  323         ndarray::Array<Scalar const,2,1> 
const & 
x,
 
  324         ndarray::Array<Scalar const,1,0> 
const & 
w,
 
  339         ndarray::Array<Scalar const,2,1> 
const & 
x,
 
  375     template <
typename A, 
typename B, 
typename C>
 
  376     void _evaluateDerivativesImpl(A 
const & 
x,
 
  379                                   bool computeHessian = 
true) 
const;
 
  381     template <
typename Derived>
 
  382     Scalar _computeZ(
Component const & component, Eigen::MatrixBase<Derived> 
const & 
x)
 const {
 
  383         _workspace = 
x - component._mu;
 
  384         component._sigmaLLT.matrixL().solveInPlace(_workspace);
 
  385         return _workspace.squaredNorm();
 
  389     void updateDampedSigma(
int k, 
Matrix const & 
sigma, 
double tau1, 
double tau2);
 
  399     mutable Vector _workspace;
 
  405 #endif // !LSST_MEAS_MODELFIT_Mixture_h_INCLUDED 
  
iterator begin()
Iterator and indexed access to components.
Scalar weight
Weight of this distribution in the mixture.
void updateEM(ndarray::Array< Scalar const, 2, 1 > const &x, UpdateRestriction const &restriction, Scalar tau1=0.0, Scalar tau2=0.5)
Perform an Expectation-Maximization step, updating the component parameters to match the given unweig...
virtual boost::shared_ptr< Mixture > clone() const
Polymorphic deep copy.
const_iterator begin() const
std::size_t size() const
Return the number of components.
Component const  & operator[](std::size_t i) const
void setMu(Vector const &mu)
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
An object passed to Persistable::write to allow it to persist itself.
MixtureComponent(int dim)
Default-construct a mixture component with weight=1, mu=0, sigma=identity.
std::vector< Component > ComponentList
MixtureComponent(Scalar weight_, Vector const &mu, Matrix const &sigma)
Default-construct a mixture component with the given parameters.
double Scalar
Typedefs to be used for probability and parameter values.
afw::table::Key< double > sigma
void setDegreesOfFreedom(Scalar df=std::numeric_limits< Scalar >::infinity())
Set the number of degrees of freedom in the component Student's T distributions (inf=Gaussian)
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Helper class used to define restrictions to the form of the component parameters in Mixture::updateEM...
Matrix getSigma() const
Get/set the shape/size parameter.
A weighted Student's T or Gaussian distribution used as a component in a Mixture.
const_iterator end() const
std::size_t clip(Scalar threshold=0.0)
Iterate over all components, removing those with weight less than or equal to threshold.
virtual int getComponentCount() const
Return the number of components.
ComponentList::const_iterator const_iterator
friend std::ostream & operator<<(std::ostream &os, Mixture const &self)
void evaluateComponents(ndarray::Array< Scalar const, 2, 1 > const &x, ndarray::Array< Scalar, 2, 1 > const &p) const
Evaluate the contributions of each component to the full probability at the given points.
int getDimension() const
Return the number of dimensions.
Scalar getDegreesOfFreedom() const
Get the number of degrees of freedom in the component Student's T distributions (inf=Gaussian)
ItemVariant const  * other
virtual ~MixtureUpdateRestriction()
MixtureComponent Component
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
friend std::ostream & operator<<(std::ostream &os, MixtureComponent const &self)
void setSigma(Matrix const &sigma)
boost::shared_ptr< Mixture > project(int dim) const
Project the distribution onto the given dimensions (marginalize over all others)
void shift(int dim, Scalar offset)
Shift the mixture in the given dimension, adding the given offset to all mu vectors.
MixtureUpdateRestriction UpdateRestriction
A base class for image defects.
void evaluateDerivatives(Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &x, Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &gradient) const
Evaluate the derivative of the distribution at the given point.
Vector getMu() const
Get/set the location parameter (mean/median/mode) of this component.
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
void updateEM(ndarray::Array< Scalar const, 2, 1 > const &x, ndarray::Array< Scalar const, 1, 0 > const &w, UpdateRestriction const &restriction, Scalar tau1=0.0, Scalar tau2=0.5)
Perform an Expectation-Maximization step, updating the component parameters to match the given weight...
A base class for objects that can be persisted via afw::table::io Archive classes.
boost::shared_ptr< Mixture > project(int dim1, int dim2) const
Project the distribution onto the given dimensions (marginalize over all others)
Scalar evaluate(Component const &component, Eigen::MatrixBase< Derived > const &x) const
Evaluate the probability density at the given point for the given component distribution.
void evaluateDerivatives(Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &x, Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &gradient, Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &hessian) const
Evaluate the derivative of the distribution at the given point.
A class that can be used to generate sequences of random numbers according to a number of different a...
MixtureUpdateRestriction(int dim)
void normalize()
Iterate over all components, rescaling their weights so they sum to one.
void evaluateDerivatives(ndarray::Array< Scalar const, 1, 1 > const &x, ndarray::Array< Scalar, 1, 1 > const &gradient, ndarray::Array< Scalar, 2, 1 > const &hessian) const
Evaluate the derivative of the distribution at the given point.
void updateEM(ndarray::Array< Scalar const, 2, 1 > const &x, ndarray::Array< Scalar const, 1, 0 > const &w, Scalar tau1=0.0, Scalar tau2=0.5)
Perform an Expectation-Maximization step, updating the component parameters to match the given weight...
virtual bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Mixture(int dim, ComponentList &components, Scalar df=std::numeric_limits< Scalar >::infinity())
Construct a mixture model.
Component & operator[](std::size_t i)
A CRTP facade class for subclasses of Persistable.
MixtureComponent project(int dim) const
Project the distribution onto the given dimension (marginalize over all others)
virtual void restrictSigma(Matrix &sigma) const
ComponentList::iterator iterator
virtual void restrictMu(Vector &mu) const
MixtureComponent & operator=(MixtureComponent const &other)
MixtureComponent project(int dim1, int dim2) const
Project the distribution onto the given dimensions (marginalize over all others)
table::Key< table::Array< int > > components
int getDimension() const
Return the number of dimensions.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
void draw(afw::math::Random &rng, ndarray::Array< Scalar, 2, 1 > const &x) const
Draw random variates from the distribution.
Scalar evaluate(Eigen::MatrixBase< Derived > const &x) const
Evaluate the mixture distribution probability density function (PDF) at the given points.
void evaluate(ndarray::Array< Scalar const, 2, 1 > const &x, ndarray::Array< Scalar, 1, 0 > const &p) const
Evaluate the distribution probability density function (PDF) at the given points.