LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
lsst::meas::modelfit::Prior Class Referenceabstract

Base class for Bayesian priors. More...

#include <Prior.h>

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

Public Member Functions

std::string const & getTag () const
 
virtual Scalar evaluate (ndarray::Array< Scalar const, 1, 1 > const &nonlinear, ndarray::Array< Scalar const, 1, 1 > const &amplitudes) const =0
 Evaluate the prior at the given point in nonlinear and amplitude space.
 
virtual 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 =0
 Evaluate the derivatives of the prior at the given point in nonlinear and amplitude space.
 
virtual Scalar marginalize (Vector const &gradient, Matrix const &hessian, ndarray::Array< Scalar const, 1, 1 > const &nonlinear) const =0
 Return the -log amplitude integral of the prior*likelihood product.
 
virtual Scalar maximize (Vector const &gradient, Matrix const &hessian, ndarray::Array< Scalar const, 1, 1 > const &nonlinear, ndarray::Array< Scalar, 1, 1 > const &amplitudes) const =0
 Compute the amplitude vector that maximizes the prior x likelihood product.
 
virtual void drawAmplitudes (Vector const &gradient, Matrix const &hessian, 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 =0
 Draw a set of Monte Carlo amplitude vectors.
 
virtual ~Prior ()
 
 Prior (const Prior &)=delete
 
Prioroperator= (const Prior &)=delete
 
 Prior (Prior &&)=delete
 
Prioroperator= (Prior &&)=delete
 

Protected Member Functions

 Prior (std::string const &tag="")
 

Detailed Description

Base class for Bayesian priors.

Definition at line 36 of file Prior.h.

Constructor & Destructor Documentation

◆ ~Prior()

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

Definition at line 161 of file Prior.h.

161{}

◆ Prior() [1/3]

lsst::meas::modelfit::Prior::Prior ( const Prior & )
delete

◆ Prior() [2/3]

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

◆ Prior() [3/3]

lsst::meas::modelfit::Prior::Prior ( std::string const & tag = "")
inlineexplicitprotected

Definition at line 173 of file Prior.h.

173: _tag(tag) {}

Member Function Documentation

◆ drawAmplitudes()

virtual void lsst::meas::modelfit::Prior::drawAmplitudes ( Vector const & gradient,
Matrix const & hessian,
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
pure virtual

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.

Implemented in lsst::meas::modelfit::MixturePrior, lsst::meas::modelfit::SemiEmpiricalPrior, and lsst::meas::modelfit::SoftenedLinearPrior.

◆ evaluate()

virtual Scalar lsst::meas::modelfit::Prior::evaluate ( ndarray::Array< Scalar const, 1, 1 > const & nonlinear,
ndarray::Array< Scalar const, 1, 1 > const & amplitudes ) const
pure virtual

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

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

Implemented in lsst::meas::modelfit::MixturePrior, lsst::meas::modelfit::SemiEmpiricalPrior, and lsst::meas::modelfit::SoftenedLinearPrior.

◆ evaluateDerivatives()

virtual void lsst::meas::modelfit::Prior::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
pure virtual

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].

Implemented in lsst::meas::modelfit::MixturePrior, lsst::meas::modelfit::SemiEmpiricalPrior, and lsst::meas::modelfit::SoftenedLinearPrior.

◆ getTag()

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

Definition at line 39 of file Prior.h.

39{ return _tag; }

◆ marginalize()

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

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\).

Implemented in lsst::meas::modelfit::MixturePrior, lsst::meas::modelfit::SemiEmpiricalPrior, and lsst::meas::modelfit::SoftenedLinearPrior.

◆ maximize()

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

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.

Implemented in lsst::meas::modelfit::MixturePrior, lsst::meas::modelfit::SemiEmpiricalPrior, and lsst::meas::modelfit::SoftenedLinearPrior.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

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