LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
lsst::meas::modelfit::MixturePrior Class Reference

A prior that's flat in amplitude parameters, and uses a Mixture for nonlinear parameters. More...

#include <MixturePrior.h>

Inheritance diagram for lsst::meas::modelfit::MixturePrior:
lsst::meas::modelfit::Prior

Public Member Functions

 MixturePrior (std::shared_ptr< Mixture const > mixture, std::string const &tag="")
 
Scalar evaluate (ndarray::Array< Scalar const, 1, 1 > const &nonlinear, ndarray::Array< Scalar const, 1, 1 > const &amplitudes) const override
 Evaluate the prior at the given point in nonlinear and amplitude space.
 
void evaluateDerivatives (ndarray::Array< Scalar const, 1, 1 > const &nonlinear, ndarray::Array< Scalar const, 1, 1 > const &amplitudes, ndarray::Array< Scalar, 1, 1 > const &nonlinearGradient, ndarray::Array< Scalar, 1, 1 > const &amplitudeGradient, ndarray::Array< Scalar, 2, 1 > const &nonlinearHessian, ndarray::Array< Scalar, 2, 1 > const &amplitudeHessian, ndarray::Array< Scalar, 2, 1 > const &crossHessian) const override
 Evaluate the derivatives of the prior at the given point in nonlinear and amplitude space.
 
Scalar marginalize (Vector const &gradient, Matrix const &hessian, ndarray::Array< Scalar const, 1, 1 > const &nonlinear) const override
 Return the -log amplitude integral of the prior*likelihood product.
 
Scalar maximize (Vector const &gradient, Matrix const &hessian, ndarray::Array< Scalar const, 1, 1 > const &nonlinear, ndarray::Array< Scalar, 1, 1 > const &amplitudes) const override
 Compute the amplitude vector that maximizes the prior x likelihood product.
 
void drawAmplitudes (Vector const &gradient, Matrix const &fisher, ndarray::Array< Scalar const, 1, 1 > const &nonlinear, afw::math::Random &rng, ndarray::Array< Scalar, 2, 1 > const &amplitudes, ndarray::Array< Scalar, 1, 1 > const &weights, bool multiplyWeights=false) const override
 Draw a set of Monte Carlo amplitude vectors.
 
std::shared_ptr< Mixture const > getMixture () const
 
std::string const & getTag () const
 

Static Public Member Functions

static MixtureUpdateRestriction const & getUpdateRestriction ()
 Return a MixtureUpdateRestriction appropriate for (e1,e2,r) data.
 

Detailed Description

A prior that's flat in amplitude parameters, and uses a Mixture for nonlinear parameters.

Definition at line 35 of file MixturePrior.h.

Constructor & Destructor Documentation

◆ MixturePrior()

lsst::meas::modelfit::MixturePrior::MixturePrior ( std::shared_ptr< Mixture const > mixture,
std::string const & tag = "" )
explicit

Member Function Documentation

◆ drawAmplitudes()

void lsst::meas::modelfit::MixturePrior::drawAmplitudes ( Vector const & gradient,
Matrix const & fisher,
ndarray::Array< Scalar const, 1, 1 > const & nonlinear,
afw::math::Random & rng,
ndarray::Array< Scalar, 2, 1 > const & amplitudes,
ndarray::Array< Scalar, 1, 1 > const & weights,
bool multiplyWeights = false ) const
overridevirtual

Draw a set of Monte Carlo amplitude vectors.

This provides a Monte Carlo approach to extracting the conditional amplitude distribution that is integrated by the marginalize() method.

Parameters
[in]gradientGradient of the -log likelihood in \(\alpha\) at fixed \(\theta\).
[in]hessianSecond derivatives of of the -log likelihood in \(\alpha\) at fixed \(\theta\).
[in]nonlinearThe nonlinear parameters \(\theta\) at which we are evaluating the conditional distribution \(P(\alpha|\theta)\).
[in,out]rngRandom number generator.
[out]amplitudesThe Monte Carlo sample of amplitude parameters \(\alpha\). The number of rows sets the number of samples, while the number of columns must match the dimensionality of \(\alpha\).
[out]weightsThe weights of the Monte Carlo samples; should asymptotically average to one.
[in]multiplyWeightsIf true, multiply weight vector instead of overwriting it.

Implements lsst::meas::modelfit::Prior.

◆ evaluate()

Scalar lsst::meas::modelfit::MixturePrior::evaluate ( ndarray::Array< Scalar const, 1, 1 > const & nonlinear,
ndarray::Array< Scalar const, 1, 1 > const & amplitudes ) const
overridevirtual

Evaluate the prior at the given point in nonlinear and amplitude space.

Parameters
[in]nonlinearVector of nonlinear parameters
[in]amplitudesVector of linear parameters

Implements lsst::meas::modelfit::Prior.

◆ evaluateDerivatives()

void lsst::meas::modelfit::MixturePrior::evaluateDerivatives ( ndarray::Array< Scalar const, 1, 1 > const & nonlinear,
ndarray::Array< Scalar const, 1, 1 > const & amplitudes,
ndarray::Array< Scalar, 1, 1 > const & nonlinearGradient,
ndarray::Array< Scalar, 1, 1 > const & amplitudeGradient,
ndarray::Array< Scalar, 2, 1 > const & nonlinearHessian,
ndarray::Array< Scalar, 2, 1 > const & amplitudeHessian,
ndarray::Array< Scalar, 2, 1 > const & crossHessian ) const
overridevirtual

Evaluate the derivatives of the prior at the given point in nonlinear and amplitude space.

Note that while the model is linear in the amplitudes, the prior is not necessarily linear in the amplitudes, so we do care about second derivatives w.r.t. amplitudes.

Parameters
[in]nonlinearVector of nonlinear parameters
[in]amplitudesVector of linear parameters
[in]nonlinearGradientFirst derivative w.r.t. nonlinear parameters
[in]amplitudeGradientFirst derivative w.r.t. linear parameters parameters
[in]nonlinearHessianSecond derivative w.r.t. nonlinear parameters
[in]amplitudeHessianSecond derivative w.r.t. linear parameters parameters
[in]crossHessianSecond derivative cross term of d(nonlinear)d(amplitudes); shape is [nonlinearDim, amplitudeDim].

Implements lsst::meas::modelfit::Prior.

◆ getMixture()

std::shared_ptr< Mixture const > lsst::meas::modelfit::MixturePrior::getMixture ( ) const
inline

Definition at line 88 of file MixturePrior.h.

88{ return _mixture; }

◆ getTag()

std::string const & lsst::meas::modelfit::Prior::getTag ( ) const
inlineinherited

Definition at line 39 of file Prior.h.

39{ return _tag; }

◆ getUpdateRestriction()

static MixtureUpdateRestriction const & lsst::meas::modelfit::MixturePrior::getUpdateRestriction ( )
static

Return a MixtureUpdateRestriction appropriate for (e1,e2,r) data.

This restriction object can be used with Mixture<3>::updateEM() to create a mixture with a strictly isotropic ellipticity distribution.

◆ marginalize()

Scalar lsst::meas::modelfit::MixturePrior::marginalize ( Vector const & gradient,
Matrix const & hessian,
ndarray::Array< Scalar const, 1, 1 > const & nonlinear ) const
overridevirtual

Return the -log amplitude integral of the prior*likelihood product.

If \(\alpha\) are the amplitudes, \(\theta\) are the nonlinear parameters, and \(D\) is the data, then this method represents \(P(\alpha,\theta)\) by computing

\[ -\ln\left[\int\!P(D|\alpha,\theta)\,P(\alpha,\theta)\,d\alpha\right] \]

at fixed \(\theta\). Because \(\alpha\) are linear parameters, \(P(D|\alpha,\theta)\) is Gaussian in \(\alpha\), and because \(\theta\) is fixed, it's usually convenient to think of the integral as:

\[ -ln\left[P(\theta)\int\!P(D|\alpha,\theta)\,P(\alpha|\theta)\,d\alpha\right] \]

Thus, we marginalize the likelihood in \(\alpha\) at fixed \(\theta\), and then multiply by the prior on \(\theta\).

We also assume the likelihood \(P(D|\alpha,\theta)\) is Gaussian in \(\alpha\), which is generally true because \(\alpha\) defined such that the model is linear in them, and the noise on the data is generally Gaussian. In detail, we represent the likelihood at fixed \(\theta\) as

\[ P(D|\alpha,\theta) = A e^{-g^T\alpha - \frac{1}{2}\alpha^T H \alpha} \]

The normalization \(A\) can be brought outside the integral as a constant to be added to the return value, so it is not passed as an argument to this function.

Parameters
[in]gradientGradient of the -log likelihood in \(\alpha\) at fixed \(\theta\); the vector \(g\) in the equation above.
[in]hessianSecond derivatives of of the -log likelihood in \(\alpha\) at fixed \(\theta\); the matrix \(H\) in the equation above.
[in]nonlinearThe nonlinear parameters \(\theta\).

Implements lsst::meas::modelfit::Prior.

◆ maximize()

Scalar lsst::meas::modelfit::MixturePrior::maximize ( Vector const & gradient,
Matrix const & hessian,
ndarray::Array< Scalar const, 1, 1 > const & nonlinear,
ndarray::Array< Scalar, 1, 1 > const & amplitudes ) const
overridevirtual

Compute the amplitude vector that maximizes the prior x likelihood product.

Parameters
[in]gradientGradient of the -log likelihood in \(\alpha\) at fixed \(\theta\); the vector \(g\) in the equation above.
[in]hessianSecond derivatives of of the -log likelihood in \(\alpha\) at fixed \(\theta\); the matrix \(H\) in the equation above.
[in]nonlinearThe nonlinear parameters \(\theta\).
[out]amplitudesThe posterior-maximum amplitude parameters \(\alpha\).
Returns
The -log(posterior) at the computed amplitude point.

Implements lsst::meas::modelfit::Prior.


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