手写高斯牛顿求解非线性最小二乘问题

在这里插入图片描述

容易写错的地方:

  • 注意你的residual定义是 z-h(x), 还是 h(x) - z,这会影响到Hx=b的符号。(自己推一遍就知道了),我的习惯性定义是z-h(x)
class GaussianNewtonOptimizer {
   
  // Observation: [x, y]
  // y = std::exp(a*x^2 + b*x + c)
  // state: [a, b, c]
  // J = std::exp(a*x^2 + b*x + c) * [x^2, x, 1]
  // residual = y - f(x; a, b, c)

 public:
  void Initialize(const Eigen::Vector3d &state, const Eigen::Vector3d &state_gt,
                  int max_iteration) {
   
    state_ = state;
    state_gt_ = state_gt;
    max_iteration_ = max_iteration;

  double MeasurementModelFunc(double observation) {
   
    return std::exp(state_[0] * observation * observation +
                    state_[1] * observation + state_[2]);
  }

  Eige
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值