File Likelihood.h

namespace lsst

Class for a simple mapping implementing a generic AstrometryTransform.

Remove all non-astronomical counts from the Chunk Exposure’s pixels.

Forward declarations for lsst::utils::Cache

For details on the Cache class, see the Cache.h file.

It uses a template rather than a pointer so that the derived classes can use the specifics of the transform. The class simplePolyMapping overloads a few routines.

A base class for image defects

Numeric constants used by the Integrate.h integrator routines.

Compute Image Statistics

Note

Gauss-Kronrod-Patterson quadrature coefficients for use in quadpack routine qng. These coefficients were calculated with 101 decimal digit arithmetic by L. W. Fullerton, Bell Labs, Nov 1981.

Note

The Statistics class itself can only handle lsst::afw::image::MaskedImage() types. The philosophy has been to handle other types by making them look like lsst::afw::image::MaskedImage() and reusing that code. Users should have no need to instantiate a Statistics object directly, but should use the overloaded makeStatistics() factory functions.

namespace meas
namespace modelfit
class Likelihood
#include <Likelihood.h>

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.

Subclassed by lsst::meas::modelfit::MultiShapeletPsfLikelihood, lsst::meas::modelfit::UnitTransformedLikelihood

Public Functions

int getDataDim() const

Return the number of data points.

int getAmplitudeDim() const

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

int getNonlinearDim() const

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

int getFixedDim() const

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

ndarray::Array<Scalar const, 1, 1> getFixed() const

Return the vector of fixed nonlinear parameters.

ndarray::Array<Pixel const, 1, 1> getData() const

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

ndarray::Array<Pixel const, 1, 1> getUnweightedData() const

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

ndarray::Array<Pixel const, 1, 1> getWeights() const

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

Will be an empty array if no weights are applied.

ndarray::Array<Pixel const, 1, 1> getVariance() const

Return the vector of per-data-point variances.

PTR(Model) const

Return an object that defines the model and its parameters.

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.

Parameters
  • [out] modelMatrix: The 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] nonlinear: Vector of nonlinear parameters at which to evaluate the model.

  • [in] doApplyWeights: If False, do not apply the weights to the modelMatrix.

virtual ~Likelihood()
Likelihood(const Likelihood&)
Likelihood &operator=(const Likelihood&)
Likelihood(Likelihood&&)
Likelihood &operator=(Likelihood&&)

Protected Functions

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

Protected Attributes

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