Covariance with LocalParameterization

693 views
Skip to first unread message

Nima Keivan

unread,
Mar 27, 2014, 3:55:16 PM3/27/14
to ceres-...@googlegroups.com
When using ceres::Covariance to obtain the covariance for given parameter blocks, is it possible to obtain the covariances in the local parameter space? In most cases the LocalParameterization is used to remedy overparameterization and the covariance in the original parameter space is singular. At the moment, ceres::Covariance is returning the covariance in the original parameter space. Is there any way to return the local parameter covariance? Or does that require manually solving for the covariance by evaluating the jacobian and forward/back substituting for the covariance columns?

Thanks in advance.

Sameer Agarwal

unread,
Mar 27, 2014, 4:05:49 PM3/27/14
to ceres-...@googlegroups.com
Nima,

Yes the covariance in the original space is singular. If you look inside CovarianceImpl, we compute the covariance matrix (if you can call it that) in the tangent space and then lift it into the ambient space using the local parameterization. 

So technically yes you can get access to it, but it harder to interpret that quantity. You could also just undo the lifting using the value of the local parameterization jacobian.

I am curious why do you want the tangent space version of the covariance matrix?

Sameer




On Thu, Mar 27, 2014 at 12:55 PM, Nima Keivan <nim...@gmail.com> wrote:
When using ceres::Covariance to obtain the covariance for given parameter blocks, is it possible to obtain the covariances in the local parameter space? In most cases the LocalParameterization is used to remedy overparameterization and the covariance in the original parameter space is singular. At the moment, ceres::Covariance is returning the covariance in the original parameter space. Is there any way to return the local parameter covariance? Or does that require manually solving for the covariance by evaluating the jacobian and forward/back substituting for the covariance columns?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/d191fa0d-3620-4130-be57-12c3e2e966b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nima Keivan

unread,
Mar 27, 2014, 4:24:27 PM3/27/14
to ceres-...@googlegroups.com
Hi Sameer,

I'm interested in doing some consistency analysis on an optimization over SE3 poses, and so I'm interested in obtaining the covariance over the tangent space to check for bias and consistency as the original parameter space is overparameterized and doesn't represent the uncertainty of the degrees of freedom being optimized. 

Do you think it would be possible to add an option to the covariance estimation to return the covariance in terms of the local parameters? If not I think the only other option is manually evaluate the Jacobian and forward/backward solve for each column of the covariance?

Sameer Agarwal

unread,
Mar 27, 2014, 4:33:28 PM3/27/14
to ceres-...@googlegroups.com
On Thu, Mar 27, 2014 at 1:24 PM, Nima Keivan <nim...@gmail.com> wrote:
Hi Sameer,

I'm interested in doing some consistency analysis on an optimization over SE3 poses, and so I'm interested in obtaining the covariance over the tangent space to check for bias and consistency as the original parameter space is overparameterized and doesn't represent the uncertainty of the degrees of freedom being optimized. 

Do you think it would be possible to add an option to the covariance estimation to return the covariance in terms of the local parameters? If not I think the only other option is manually evaluate the Jacobian and forward/backward solve for each column of the covariance?

It is reasonably straightforward to add a GetCovarianceBlockInTangentSpace method to Covariance. But it will take me a bit to get to it, my plate is rather full right now. So either you can send me a patch by looking at the implementation of GetCovariance and just dropping the local parameterization stuff. 

Or you can get the covariance block in the lifted space, and then pre and post multiply with the pseudo inverse of the local parameterization jacobian.

The covariance block we are returning is 

     C = J' C_p J

if J' = QR

then you can you can see that 

C = QRC_pR'Q'

pre and post multiplying by 

R^-1Q' will give you

R^{-1}Q' C Q R{-T} = C_p

which is what you need.

Sameer

 


On Thursday, 27 March 2014 16:05:49 UTC-4, Sameer Agarwal wrote:
Nima,

Yes the covariance in the original space is singular. If you look inside CovarianceImpl, we compute the covariance matrix (if you can call it that) in the tangent space and then lift it into the ambient space using the local parameterization. 

So technically yes you can get access to it, but it harder to interpret that quantity. You could also just undo the lifting using the value of the local parameterization jacobian.

I am curious why do you want the tangent space version of the covariance matrix?

Sameer




On Thu, Mar 27, 2014 at 12:55 PM, Nima Keivan <nim...@gmail.com> wrote:
When using ceres::Covariance to obtain the covariance for given parameter blocks, is it possible to obtain the covariances in the local parameter space? In most cases the LocalParameterization is used to remedy overparameterization and the covariance in the original parameter space is singular. At the moment, ceres::Covariance is returning the covariance in the original parameter space. Is there any way to return the local parameter covariance? Or does that require manually solving for the covariance by evaluating the jacobian and forward/back substituting for the covariance columns?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.

Nima Keivan

unread,
Mar 27, 2014, 4:52:32 PM3/27/14
to ceres-...@googlegroups.com
Thanks Sameer. I think I might have a look at writing a quick patch to add an option to the covariance to calculate it in the local parameter space.

Sameer Agarwal

unread,
Mar 27, 2014, 4:55:04 PM3/27/14
to ceres-...@googlegroups.com
Sounds great, please be sure to extend the tests to cover the API.


Jesús Pestana Puerta

unread,
Jul 20, 2015, 4:13:36 AM7/20/15
to ceres-...@googlegroups.com
Hi Sameer,

I am working on a visual-based localization on real-time; and I needed to calculate the covariance matrix in the local or tangent space for part of my calculations. So I followed your instructions from this forum conversation and have done the following modifications to ceres-1.10.0:
  • Create the CovarianceImpl::GetCovarianceBlockTangentSpace based on the code from CovarianceImpl::GetCovarianceBlock . It was actually simple once I understood what the code was doing (as you said, the covariance matrix in the tangent space was already calculated by the GetCovarianceBlock function). The new function can be used also for parameters that do not have a local parameterization.
  • Added a wrapper to this function Covariance::GetCovarianceBlockTangentSpace (similarly to the existing wrapper Covariance::GetCovarianceBlock)
  • I have modified the test code for the covariance calculation in covariance_test.cc to cover also the new GetCovarianceBlockTangentSpace API function. 
  • In the covariance_test.cc there was a small documentation error in the test case "TEST_F(CovarianceTest, LocalParameterization)". The "Global to local jacobian A" (which might actually be the "local to global jacobian A") should not have the forth column because of the SubsetParameterization for the parameter_ "y" (this gave problems testing the GetCovarianceBlockTangentSpace function).
I think that my current implementation of this function is correct. Would it be interesting to try to push the changes for the next version of the ceres-solver?

Thanks a lot for your work on the ceres-solver!

Jesús Pestana

Sameer Agarwal

unread,
Jul 20, 2015, 4:17:28 AM7/20/15
to ceres-...@googlegroups.com
Jesus,

Covariance::GetCovarianceBlockInTangentSpace already exists in the version of Ceres in the git repo. Steve Hsu added this in commit #  a1579be


Sameer


Jesús Pestana Puerta

unread,
Jul 20, 2015, 4:22:58 AM7/20/15
to ceres-...@googlegroups.com
Ah ok! Actually, I always downloaded the code directly from the website... I will start getting it from the Gerrit repo.

Thanks a lot for the information Sameer,

Jesús

Sameer Agarwal

unread,
Jul 20, 2015, 4:28:43 AM7/20/15
to ceres-...@googlegroups.com
You can use Gerrit or GitHub (https://github.com/ceres-solver/ceres-solver). It is only a minute or so behind the gerrit repo.
Sameer


Paul Ozog

unread,
Jul 26, 2016, 3:54:15 PM7/26/16
to Ceres Solver
Hi Sameer,

The documentation is a little unclear if covariance recovery works for large problems using a LocalParameterization when algorithm_type is set to SPARSE_CHOLESKY or SPARSE_QR.

It says:

Neither SPARSE_CHOLESKY or SPARSE_QR are capable of computing the covariance if the Jacobian is rank deficient.

Does this statement hold if I defined a valid LocalParameterization for the parameter blocks?  I would try it out for myself but you could probably answer this faster than I can :).  Thanks

Sameer Agarwal

unread,
Jul 26, 2016, 3:56:47 PM7/26/16
to Ceres Solver
Paul,
A valid local parameterization should work just fine.
Sameer


Reply all
Reply to author
Forward
0 new messages