59 static double f(
double z,
double u,
double p) {
60 return logSqrt2PI - 0.5 *
log(p) + 0.5 * (z - u) * (z - u) *
p;
75 double e = u -
z, e2 = e *
e;
76 double c = 2 * logSqrt2PI -
log(p) + e2 *
p;
95 Base(), z_(z), meanKey_(meanKey), precisionKey_(precisionKey) {
111 void print(
const std::string&
p =
"WhiteNoiseFactor",
114 std::cout <<
p +
".z: " << z_ << std::endl;
122 size_t dim()
const override {
128 return f(z_, x.
at<
double>(meanKey_), x.
at<
double>(precisionKey_));
void print(const std::string &p="WhiteNoiseFactor", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Print.
static double f(double z, double u, double p)
negative log likelihood as a function of mean and precision
static HessianFactor::shared_ptr linearize(double z, double u, double p, Key j1, Key j2)
linearize returns a Hessianfactor that approximates error Hessian is Taylor expansion is So f = 2 f...
EIGEN_DEVICE_FUNC const LogReturnType log() const
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
static const KeyFormatter DefaultKeyFormatter
virtual Vector unwhitenedError(const Values &x) const
const double logSqrt2PI
constant needed below
const ValueType at(Key j) const
~WhiteNoiseFactor() override
Destructor.
Key meanKey_
key by which to access mean variable
double error(const Values &x) const override
Calculate the error of the factor, typically equal to log-likelihood.
boost::shared_ptr< This > shared_ptr
A shared_ptr to this class.
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Contains the HessianFactor class, a general quadratic factor.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
boost::shared_ptr< GaussianFactor > linearize(const Values &x) const override
linearize returns a Hessianfactor that is an approximation of error(p)
Non-linear factor base classes.
Key precisionKey_
key by which to access precision variable
Pose3 g1(Rot3(), Point3(100.0, 0.0, 300.0))
A Gaussian factor using the canonical parameters (information form)
Binary factor to estimate parameters of zero-mean Gaussian white noise.
WhiteNoiseFactor(double z, Key meanKey, Key precisionKey)
size_t dim() const override
get the dimension of the factor (number of rows on linearization)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Pose3 g2(g1.expmap(h *V1_g1))
std::uint64_t Key
Integer nonlinear key type.