LSST Applications g0265f82a02+c6dfa2ddaf,g1162b98a3f+ffe7eabc7e,g2079a07aa2+1b2e822518,g2bbee38e9b+c6dfa2ddaf,g337abbeb29+c6dfa2ddaf,g36da64cc00+ea84795170,g3ddfee87b4+955a963fd8,g50ff169b8f+2eb0e556e8,g52b1c1532d+90ebb246c7,g555ede804d+955a963fd8,g591dd9f2cf+bac198a2cb,g5ec818987f+420292cfeb,g858d7b2824+d6c9a0a3b8,g876c692160+aabc49a3c3,g8a8a8dda67+90ebb246c7,g8cdfe0ae6a+4fd9e222a8,g99cad8db69+e6cd765486,g9ddcbc5298+a1346535a5,ga1e77700b3+df8f93165b,ga8c6da7877+acd47f83f4,gae46bcf261+c6dfa2ddaf,gb0e22166c9+8634eb87fb,gb3f2274832+12c8382528,gba4ed39666+1ac82b564f,gbb8dafda3b+0574160a1f,gbeb006f7da+dea2fbb49f,gc28159a63d+c6dfa2ddaf,gc86a011abf+d6c9a0a3b8,gcf0d15dbbd+955a963fd8,gdaeeff99f8+1cafcb7cd4,gdc0c513512+d6c9a0a3b8,ge79ae78c31+c6dfa2ddaf,geb67518f79+ba1859f325,gee10cc3b42+90ebb246c7,gf1cff7945b+d6c9a0a3b8,w.2024.13
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
lsst::meas::modelfit::SemiEmpiricalPrior Class Reference

A piecewise prior motivated by both real distributions and practical considerations. More...

#include <SemiEmpiricalPrior.h>

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

Public Types

typedef SemiEmpiricalPriorControl Control
 

Public Member Functions

 SemiEmpiricalPrior (Control const &ctrl=Control())
 
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::string const & getTag () const
 

Detailed Description

A piecewise prior motivated by both real distributions and practical considerations.

Definition at line 84 of file SemiEmpiricalPrior.h.

Member Typedef Documentation

◆ Control

Definition at line 87 of file SemiEmpiricalPrior.h.

Constructor & Destructor Documentation

◆ SemiEmpiricalPrior()

lsst::meas::modelfit::SemiEmpiricalPrior::SemiEmpiricalPrior ( Control const & ctrl = Control())
explicit

Member Function Documentation

◆ drawAmplitudes()

void lsst::meas::modelfit::SemiEmpiricalPrior::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::SemiEmpiricalPrior::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::SemiEmpiricalPrior::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.

◆ getTag()

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

Definition at line 39 of file Prior.h.

39{ return _tag; }

◆ marginalize()

Scalar lsst::meas::modelfit::SemiEmpiricalPrior::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::SemiEmpiricalPrior::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: