24 #ifndef LSST_MEAS_MODELFIT_TruncatedGaussian_h_INCLUDED
25 #define LSST_MEAS_MODELFIT_TruncatedGaussian_h_INCLUDED
30 #include "lsst/base.h"
31 #include "lsst/afw/math/Random.h"
36 namespace lsst {
namespace meas {
namespace modelfit {
38 class TruncatedGaussianSampler;
39 class TruncatedGaussianEvaluator;
40 class TruncatedGaussianLogEvaluator;
250 template <
typename Derived>
252 if ((alpha.array() < 0.0).any())
return std::numeric_limits<Scalar>::infinity();
253 _workspace = alpha - _mu;
254 return 0.5*(_rootH*_workspace).squaredNorm() + _norm;
257 Scalar operator()(ndarray::Array<Scalar const,1,1>
const & alpha)
const;
260 ndarray::Array<Scalar const,2,1>
const & alpha,
261 ndarray::Array<Scalar,1,1>
const & output
281 template <
typename Derived>
283 return std::exp(-_internal(alpha));
286 Scalar operator()(ndarray::Array<Scalar const,1,1>
const & alpha)
const;
289 ndarray::Array<Scalar const,2,1>
const & alpha,
290 ndarray::Array<Scalar,1,1>
const & output
316 Scalar operator()(afw::math::Random & rng, ndarray::Array<Scalar,1,1>
const & alpha)
const;
328 afw::math::Random & rng,
329 ndarray::Array<Scalar,2,1>
const & alpha,
330 ndarray::Array<Scalar,1,1>
const & weights,
331 bool multiplyWeights=
false
343 return Sampler(*
this, strategy);
359 #endif // !LSST_MEAS_MODELFIT_TruncatedGaussian_h_INCLUDED
friend class TruncatedGaussianSampler
static TruncatedGaussian fromStandardParameters(Vector const &mean, Matrix const &covariance)
Create from the "standard" mean and covariance parameters of the normal distribution.
TruncatedGaussianLogEvaluator LogEvaluator
Scalar operator()(Eigen::MatrixBase< Derived > const &alpha) const
Scalar getLogPeakAmplitude() const
Return the -log of the peak amplitude of the untruncated function.
TruncatedGaussianEvaluator(TruncatedGaussian const &parent)
Helper class for drawing samples from a TruncatedGaussian.
double Scalar
Typedefs to be used for probability and parameter values.
int getDim() const
Return the dimensionality of the function.
friend class TruncatedGaussianLogEvaluator
Scalar operator()(Eigen::MatrixBase< Derived > const &alpha) const
LogEvaluator evaluateLog() const
Create a LogEvaluator object that can be used to efficiently evaluate the -log of the function...
Evaluator evaluate() const
Create an Evaluator object that can be used to efficiently evaluate the function. ...
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
Typedefs to be used for probability and parameter values.
Represents a multidimensional Gaussian function truncated at zero.
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Typedefs to be used for probability and parameter values.
Sampler sample(SampleStrategy strategy) const
Create a Sampler object that uses the given strategy.
SampleStrategy
Enum that describes different ways of sampling from a multidimensional TruncatedGaussian.
Helper class for evaluating the -log of a TruncatedGaussian.
Create a similar Gaussian with no x-y covariance, and importance sample by drawing from the independe...
Scalar getUntruncatedFraction() const
Return the fraction of the Gaussian integral that was truncated by the bounds.
Helper class for evaluating the -log of a TruncatedGaussian.
Draw from the untruncated Gaussian, and discard negative draws.
Vector maximize() const
Return the location of the maximum of the truncated Gaussian.
TruncatedGaussianEvaluator Evaluator
TruncatedGaussianSampler Sampler
Scalar getLogIntegral() const
Return the -log of the integral of the truncated function.
static TruncatedGaussian fromSeriesParameters(Scalar q0, Vector const &gradient, Matrix const &hessian)
Create from the first and second logarithmic derivatives of the Gaussian.