Class Prior

Inheritance Relationships

Derived Types

Class Documentation

class Prior

Base class for Bayesian priors.

Subclassed by lsst::meas::modelfit::MixturePrior, lsst::meas::modelfit::SemiEmpiricalPrior, lsst::meas::modelfit::SoftenedLinearPrior

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

Parameters
  • [in] nonlinear: Vector of nonlinear parameters

  • [in] amplitudes: Vector of linear parameters

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.

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

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.

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

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.

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

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.

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.

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

Protected Functions

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