Class SoftenedLinearPrior¶
Defined in File SoftenedLinearPrior.h
Inheritance Relationships¶
Base Type¶
public lsst::meas::modelfit::Prior
(Class Prior)
Class Documentation¶
-
class
SoftenedLinearPrior
: public lsst::meas::modelfit::Prior¶ A prior that’s linear in radius and flat in ellipticity, with a cubic roll-off at the edges.
Public Types
-
typedef SoftenedLinearPriorControl
Control
¶
Public Functions
-
Scalar
evaluate
(ndarray::Array<Scalar const, 1, 1> const &nonlinear, ndarray::Array<Scalar const, 1, 1> const &litudes) const¶ Evaluate the prior at the given point in nonlinear and amplitude space.
- Parameters
[in] nonlinear
: Vector of nonlinear parameters[in] amplitudes
: Vector of linear parameters
-
void
evaluateDerivatives
(ndarray::Array<Scalar const, 1, 1> const &nonlinear, ndarray::Array<Scalar const, 1, 1> const &litudes, ndarray::Array<Scalar, 1, 1> const &nonlinearGradient, ndarray::Array<Scalar, 1, 1> const &litudeGradient, ndarray::Array<Scalar, 2, 1> const &nonlinearHessian, ndarray::Array<Scalar, 2, 1> const &litudeHessian, ndarray::Array<Scalar, 2, 1> const &crossHessian) const¶ 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] nonlinear
: Vector of nonlinear parameters[in] amplitudes
: Vector of linear parameters[in] nonlinearGradient
: First derivative w.r.t. nonlinear parameters[in] amplitudeGradient
: First derivative w.r.t. linear parameters parameters[in] nonlinearHessian
: Second derivative w.r.t. nonlinear parameters[in] amplitudeHessian
: Second derivative w.r.t. linear parameters parameters[in] crossHessian
: Second derivative cross term of d(nonlinear)d(amplitudes); shape is [nonlinearDim, amplitudeDim].
-
Scalar
marginalize
(Vector const &gradient, Matrix const &hessian, ndarray::Array<Scalar const, 1, 1> const &nonlinear) const¶ 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] gradient
: Gradient of the -log likelihood in \(\alpha\) at fixed \(\theta\); the vector \(g\) in the equation above.[in] hessian
: Second derivatives of of the -log likelihood in \(\alpha\) at fixed \(\theta\); the matrix \(H\) in the equation above.[in] nonlinear
: The nonlinear parameters \(\theta\).
-
Scalar
maximize
(Vector const &gradient, Matrix const &hessian, ndarray::Array<Scalar const, 1, 1> const &nonlinear, ndarray::Array<Scalar, 1, 1> const &litudes) const¶ Compute the amplitude vector that maximizes the prior x likelihood product.
- Return
The -log(posterior) at the computed amplitude point.
- Parameters
[in] gradient
: Gradient of the -log likelihood in \(\alpha\) at fixed \(\theta\); the vector \(g\) in the equation above.[in] hessian
: Second derivatives of of the -log likelihood in \(\alpha\) at fixed \(\theta\); the matrix \(H\) in the equation above.[in] nonlinear
: The nonlinear parameters \(\theta\).[out] amplitudes
: The posterior-maximum amplitude parameters \(\alpha\).
-
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 &litudes, ndarray::Array<Scalar, 1, 1> const &weights, bool multiplyWeights = false) const¶ 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] gradient
: Gradient of the -log likelihood in \(\alpha\) at fixed \(\theta\).[in] hessian
: Second derivatives of of the -log likelihood in \(\alpha\) at fixed \(\theta\).[in] nonlinear
: The nonlinear parameters \(\theta\) at which we are evaluating the conditional distribution \(P(\alpha|\theta)\).[inout] rng
: Random number generator.[out] amplitudes
: The 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] weights
: The weights of the Monte Carlo samples; should asymptotically average to one.[in] multiplyWeights
: If true, multiply weight vector instead of overwriting it.
-
typedef SoftenedLinearPriorControl