LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lsst::meas::modelfit::Likelihood Class Referenceabstract

Base class for optimizer/sampler likelihood functions that compute likelihood at a point. More...

#include <Likelihood.h>

Inheritance diagram for lsst::meas::modelfit::Likelihood:
lsst::meas::modelfit::MultiShapeletPsfLikelihood lsst::meas::modelfit::UnitTransformedLikelihood

Public Member Functions

int getDataDim () const
 Return the number of data points. More...
 
int getAmplitudeDim () const
 Return the number of linear parameters (columns of the model matrix) More...
 
int getNonlinearDim () const
 Return the number of nonlinear parameters (which parameterize the model matrix) More...
 
int getFixedDim () const
 Return the number of fixed nonlinear parameters (set on Likelihood construction) More...
 
ndarray::Array< Scalar const, 1, 1 > getFixed () const
 Return the vector of fixed nonlinear parameters. More...
 
ndarray::Array< Pixel const, 1, 1 > getData () const
 Return the vector of weighted, scaled data points \(z\). More...
 
ndarray::Array< Pixel const, 1, 1 > getUnweightedData () const
 Return the vector of unweighted data points \(y\). More...
 
ndarray::Array< Pixel const, 1, 1 > getWeights () const
 Return the vector of weights \(w\) applied to data points and model matrix rows. More...
 
ndarray::Array< Pixel const, 1, 1 > getVariance () const
 Return the vector of per-data-point variances. More...
 
std::shared_ptr< ModelgetModel () const
 Return an object that defines the model and its parameters. More...
 
virtual void computeModelMatrix (ndarray::Array< Pixel, 2,-1 > const &modelMatrix, ndarray::Array< Scalar const, 1, 1 > const &nonlinear, bool doApplyWeights=true) const =0
 Evaluate the model for the given vector of nonlinear parameters. More...
 
virtual ~Likelihood ()
 
 Likelihood (const Likelihood &)=delete
 
Likelihoodoperator= (const Likelihood &)=delete
 
 Likelihood (Likelihood &&)=delete
 
Likelihoodoperator= (Likelihood &&)=delete
 

Protected Member Functions

 Likelihood (std::shared_ptr< Model > model, ndarray::Array< Scalar const, 1, 1 > const &fixed)
 

Protected Attributes

std::shared_ptr< Model_model
 
ndarray::Array< Scalar const, 1, 1 > _fixed
 
ndarray::Array< Pixel, 1, 1 > _data
 
ndarray::Array< Pixel, 1, 1 > _unweightedData
 
ndarray::Array< Pixel, 1, 1 > _variance
 
ndarray::Array< Pixel, 1, 1 > _weights
 

Detailed Description

Base class for optimizer/sampler likelihood functions that compute likelihood at a point.

Likelihood abstracts the problem of computing the likelihood over different kinds of data. It is responsible for creating a "model matrix" that maps amplitudes to data values, and maintaining a vector of scaled, weighted data values that corresponds to it. Its components can be represented best in the mathematical formula for a -log likelihood assuming Gaussian data and a model with both nonlinear parameters \(\theta\) and linear ("amplitude") parameters \(\alpha\):

\[ L(\alpha,\theta) = \frac{1}{2}\left(y - A(\theta)\alpha\right)^T\, \Sigma^{-1}\,\left(y - A(\theta)\alpha\right) \]

where \(y\) is the data vector, \(\Sigma\) is the data covariance matrix (assumed to be diagonal), and \(A(\theta)\) is the "true" model matrix (parametrized on the nonlinear parameters).

When fitting or sampling from the likelihood, however, we don't want to use these quantities directly, and they aren't what the Likelihood class provides. Instead, we reparametrize with:

\[ w_i \equiv \Sigma_{i,i}^{-1/2} \]

\[ z_i = w_i y_i \]

\[ B_{i,j} = w_i A_{i,j} \]

resulting in the equivalent formula:

\[ L(\alpha,\theta) = \frac{1}{2}\left(z-B(\theta)\alpha\right)^T\,\left(z-B(\theta)\alpha\right) \]

The \(w_i\) are the weights, which are applied to both the data vector and the model matrix to account for the noise in the data. In some cases, we may choose to use a constant weight rather than per-pixel weights, but will will still use a vector to represent it.

Definition at line 69 of file Likelihood.h.

Constructor & Destructor Documentation

◆ ~Likelihood()

virtual lsst::meas::modelfit::Likelihood::~Likelihood ( )
inlinevirtual

Definition at line 126 of file Likelihood.h.

126 {}

◆ Likelihood() [1/3]

lsst::meas::modelfit::Likelihood::Likelihood ( const Likelihood )
delete

◆ Likelihood() [2/3]

lsst::meas::modelfit::Likelihood::Likelihood ( Likelihood &&  )
delete

◆ Likelihood() [3/3]

lsst::meas::modelfit::Likelihood::Likelihood ( std::shared_ptr< Model model,
ndarray::Array< Scalar const, 1, 1 > const &  fixed 
)
inlineprotected

Definition at line 138 of file Likelihood.h.

138  :
139  _model(model), _fixed(fixed) {
141  fixed.getSize<0>(), static_cast<std::size_t>(model->getFixedDim()),
142  pex::exceptions::LengthError,
143  "Fixed parameter vector size (%d) does not match Model fixed parameter dimensionality (%d)"
144  );
145  }
#define LSST_THROW_IF_NE(N1, N2, EXC_CLASS, MSG)
Check whether the given values are equal, and throw an LSST Exception if they are not.
Definition: asserts.h:38
std::shared_ptr< Model > _model
Definition: Likelihood.h:147
ndarray::Array< Scalar const, 1, 1 > _fixed
Definition: Likelihood.h:148
T fixed(T... args)

Member Function Documentation

◆ computeModelMatrix()

virtual void lsst::meas::modelfit::Likelihood::computeModelMatrix ( ndarray::Array< Pixel, 2,-1 > const &  modelMatrix,
ndarray::Array< Scalar const, 1, 1 > const &  nonlinear,
bool  doApplyWeights = true 
) const
pure virtual

Evaluate the model for the given vector of nonlinear parameters.

Parameters
[out]modelMatrixThe dataDim x amplitudeDim matrix \(B\) that expresses the model projected in such a way that it can be compared to the data when multiplied by an amplitude vector \(\alpha\). It should be weighted if the data vector is. The caller is responsible for guaranteeing that the shape of the matrix correct, but implementations should not assume anything about the initial values of the matrix elements.
[in]nonlinearVector of nonlinear parameters at which to evaluate the model.
[in]doApplyWeightsIf False, do not apply the weights to the modelMatrix.

Implemented in lsst::meas::modelfit::UnitTransformedLikelihood, and lsst::meas::modelfit::MultiShapeletPsfLikelihood.

◆ getAmplitudeDim()

int lsst::meas::modelfit::Likelihood::getAmplitudeDim ( ) const
inline

Return the number of linear parameters (columns of the model matrix)

Definition at line 77 of file Likelihood.h.

77 { return _model->getAmplitudeDim(); }

◆ getData()

ndarray::Array<Pixel const,1,1> lsst::meas::modelfit::Likelihood::getData ( ) const
inline

Return the vector of weighted, scaled data points \(z\).

Definition at line 89 of file Likelihood.h.

89 { return _data; }
ndarray::Array< Pixel, 1, 1 > _data
Definition: Likelihood.h:149

◆ getDataDim()

int lsst::meas::modelfit::Likelihood::getDataDim ( ) const
inline

Return the number of data points.

Definition at line 74 of file Likelihood.h.

74 { return _data.getSize<0>(); }

◆ getFixed()

ndarray::Array<Scalar const,1,1> lsst::meas::modelfit::Likelihood::getFixed ( ) const
inline

Return the vector of fixed nonlinear parameters.

Definition at line 86 of file Likelihood.h.

86 { return _fixed; }

◆ getFixedDim()

int lsst::meas::modelfit::Likelihood::getFixedDim ( ) const
inline

Return the number of fixed nonlinear parameters (set on Likelihood construction)

Definition at line 83 of file Likelihood.h.

83 { return _model->getFixedDim(); }

◆ getModel()

std::shared_ptr<Model> lsst::meas::modelfit::Likelihood::getModel ( ) const
inline

Return an object that defines the model and its parameters.

Definition at line 105 of file Likelihood.h.

105 { return _model; }

◆ getNonlinearDim()

int lsst::meas::modelfit::Likelihood::getNonlinearDim ( ) const
inline

Return the number of nonlinear parameters (which parameterize the model matrix)

Definition at line 80 of file Likelihood.h.

80 { return _model->getNonlinearDim(); }

◆ getUnweightedData()

ndarray::Array<Pixel const,1,1> lsst::meas::modelfit::Likelihood::getUnweightedData ( ) const
inline

Return the vector of unweighted data points \(y\).

Definition at line 92 of file Likelihood.h.

92 { return _unweightedData; }
ndarray::Array< Pixel, 1, 1 > _unweightedData
Definition: Likelihood.h:150

◆ getVariance()

ndarray::Array<Pixel const,1,1> lsst::meas::modelfit::Likelihood::getVariance ( ) const
inline

Return the vector of per-data-point variances.

Definition at line 102 of file Likelihood.h.

102 { return _variance; }
ndarray::Array< Pixel, 1, 1 > _variance
Definition: Likelihood.h:151

◆ getWeights()

ndarray::Array<Pixel const,1,1> lsst::meas::modelfit::Likelihood::getWeights ( ) const
inline

Return the vector of weights \(w\) applied to data points and model matrix rows.

Will be an empty array if no weights are applied.

Definition at line 99 of file Likelihood.h.

99 { return _weights; }
ndarray::Array< Pixel, 1, 1 > _weights
Definition: Likelihood.h:152

◆ operator=() [1/2]

Likelihood& lsst::meas::modelfit::Likelihood::operator= ( const Likelihood )
delete

◆ operator=() [2/2]

Likelihood& lsst::meas::modelfit::Likelihood::operator= ( Likelihood &&  )
delete

Member Data Documentation

◆ _data

ndarray::Array<Pixel,1,1> lsst::meas::modelfit::Likelihood::_data
protected

Definition at line 149 of file Likelihood.h.

◆ _fixed

ndarray::Array<Scalar const,1,1> lsst::meas::modelfit::Likelihood::_fixed
protected

Definition at line 148 of file Likelihood.h.

◆ _model

std::shared_ptr<Model> lsst::meas::modelfit::Likelihood::_model
protected

Definition at line 147 of file Likelihood.h.

◆ _unweightedData

ndarray::Array<Pixel,1,1> lsst::meas::modelfit::Likelihood::_unweightedData
protected

Definition at line 150 of file Likelihood.h.

◆ _variance

ndarray::Array<Pixel,1,1> lsst::meas::modelfit::Likelihood::_variance
protected

Definition at line 151 of file Likelihood.h.

◆ _weights

ndarray::Array<Pixel,1,1> lsst::meas::modelfit::Likelihood::_weights
protected

Definition at line 152 of file Likelihood.h.


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