Negative diagonal elements on Covariance matrix

Hi all,

Within an orbit determination scenario, I am trying to estimate some parameters involved in different measurements inside the least-squares algorithm. After running the algorithm I get estimated values for all parameters, however, when extracting the sigma values, some of them are NaN as a consequence of some negative diagonal elements on the covariance matrix. Can I trust on these estimated values?
Do you know the mathematical explanation for this behavior?

Thank you for your time,
Antonio

Hello @A.Garcia-Salcedo,

My answer might be slightly out of context; I have encountered a similar problem, where a covariance matrix had negative diagonal elements.

In my case, because the input covariance matrix was checked for being positive-definite (i.e. positive eigenvalues), the bad result was due to mis-handling the covariance matrix propagation, including incomplete frame transformations (not using orekit at that time).

Bottomline; Adding checks on the input data (matrices) with some exception handling might shed more light to the root cause. Adding checks for the condition of the matrix after every transformation (positive definite, rank, eigenvalues’ sign) might also help to narrow down the problem, if such transformations take place. I look forward to some expert’s advice too!

Hi @A.Garcia-Salcedo,

I personally don’t and it does sound weird.
Do you use the method BatchLSEstimator.getPhysicalCovariances to get the covariance matrix after the estimation process is converged?

Could you share some code with us (a Junit test case would be the best) so we can have a look at your issue?

Maxime

Thanks Manny for your answer,

I am not propagating the covariance matrix manually, what i am doing is extending the measurement abstract and doing all operations with derivative structures, at the end I extract directly the derivatives.

I have realized that fixing some of the parameters I want to estimate, this behaviour disappears (the others parameters are accurately estimated), may is linked with the degree of freedom of the system itself.

1 Like

Dear Maxime, thanks for answering,

I was extracting the covariance for the optimum, with the getPhysicalCovariances method after the estimation I also obtain some negative diagonal elements.

I am not getting used to Junit tests, what it is implemented is an OD problem with a measurement that handles the position of the spacecraft and the position of two ground stations. When I want to estimate the spacecraft orbit and the both ground stations I get this scenario. However, if I fix the position of one station, the position of the remaining one and the satellite orbit are well estimated. Could it be linked with a kind of overdetermination or degrees of freedom of the system?

Possibly yes, if you have less measurements’ components than unknown (your estimated parameters) then your system is under-determined.
How many measurements do you have and of what type?
And what exactly are you estimating ? From your last post I would say the orbit + two stations’ offset positions so 6 + 2x3 = 12 parameters. Am I correct?

A Java “main” would work too but I understand it may be a burden to extract your code so that it can be run by others.

The system is using 700 measurements of Time Difference of Arrival.
I am estimating the orbit PV vector and the east, north and zenith offset of each receiver. That’s right 12 parameters.

Ok so there should be enough measurements for the system to be determined properly.

I’m not familiar with the TDOA measurements, did you design them by yourself?

You could upoad a print of the covariance matrix, the Jacobian J of the last iteration as well as the product J^T.J (so the inverse of the covariance), maybe it will help.

But without some code or a test that reproduces the negative elements on the diagonal of the covariance matrix it will be hard to solve your issue I’m afraid…

Yes, it is an extension of Difference of Range (DOR) measurement, I have implemented the measurement starting from the range measurement of the spacecraft in one ground station. The range measurement in the second ground station is computed from the emitter position resulting from the first computation and the second ground station position at downlink date of the first station minor a delta time, this delta time is set to a certain value as initial guess and it is computed in a loop. The final value is the measurement itself. All the computations are performed with derivative structures and the derivatives are extracted at the end of this object.

In the end, you can find some values of a simulation that employs 3 ground stations, which is 2 baselines. When running several simulations with the same parameters, some outputs present reasonable values (no negative diagonal elements and real sigmas).
This uncertainty on the optimum solution only appears when both stations are estimated. If one is fixed, the estimation is more accurate and robust.

Would be enough with the implemented measurement code?

Thanks for the dedicated time.

Physical Covariance: BlockRealMatrix{{-1476079.8796600753,2411383.5303542367,15456.7153690251,-165.8865430079,-105.9196009066,2.8802148488,-470720.097561104,-177098.0572589929,-32044.7843165705,-470730.5011399422,-177095.7776601851,-32045.5932753576,-470724.880386291,-177091.8284461079,-32053.0070810181},{2379167.2772286506,-3887237.7426927676,-25311.3507403141,267.395021929,170.7761008806,-4.724489793,761369.8494417485,287004.1105544967,57100.3382264198,761386.5018007362,287000.5107791939,57101.7019671642,761377.3148401981,286993.9632507884,57113.7515981404},{-3276.9971966415,4976.9368765204,-186.6953809502,-0.35605071,-0.2000936228,-0.0387565465,308.0091216307,323.1863452858,3088.4459517363,307.9137424696,323.2393773825,3088.4780964457,307.850827447,323.1478233414,3088.5119341746},{-164.834695695,269.2976919875,1.7392496479,-0.018525174,-0.0118298314,0.0003243736,-52.6564467238,-19.8312022084,-3.7566145766,-52.6576047956,-19.8309499889,-3.7567068976,-52.6569729942,-19.8305029323,-3.757538233},{-102.9317018166,168.2061627797,1.1145802849,-0.0115694607,-0.0073912577,0.0002083642,-33.0634559993,-12.4907984644,-2.7395941903,-33.0641706126,-12.4906466141,-2.7396560307,-33.0637668504,-12.4903545547,-2.7401820811},{-0.9178938519,1.4212712565,-0.0358169705,-0.0001005966,-0.0000586442,-0.0000072762,-0.0265157275,0.0465578935,0.6199404861,-0.0265365682,0.0465692685,0.6199464332,-0.026548172,0.0465515583,0.6199521212},{-353329.7852434132,577377.1635791268,3681.6079417384,-39.7161704206,-25.3634286292,0.6758412291,-100759.060032118,-25913.9120926468,-26458.5113807253,-100760.5866171936,-25914.0469413508,-26458.7850555403,-100758.6084874166,-25912.9114732647,-26459.9628694889},{-271382.7608083718,435947.3850279925,-1709.5655271635,-30.2625468493,-18.7832742889,-0.3804725982,-30078.3429801628,68458.3152992174,11740.8171000313,-30078.1459303948,68458.1505349215,11740.1880447592,-30076.3034361111,68457.3357584531,11742.2786610081},{178158.2396254359,-282825.2828017982,3045.5671762659,19.7562631167,12.0186227144,0.6442750742,11674.2797800501,-11145.8264048908,-33169.1552652442,11675.7757606814,-11146.079252891,-33169.7799838361,11675.8498105024,-11144.7718593666,-33170.6695492631},{-353348.7856205054,577407.7739934132,3681.5467948565,-39.7182919384,-25.3647520031,0.6758259807,-100762.347680866,-25912.6137143457,-26457.3837131009,-100763.8743519174,-25912.7485492085,-26457.6573902145,-100761.8961505346,-25911.6131221314,-26458.8351580053},{-271378.1919150905,435940.0970646406,-1709.5048074686,-30.2620390087,-18.7829629989,-0.3804593184,-30078.1128689457,68457.9455033631,11740.4734532111,-30077.9157975201,68457.7807462542,11739.8443835932,-30076.0733144968,68456.9659930885,11741.9349743779},{178163.5156990085,-282833.7128660179,3045.6251371366,19.7568499375,12.0189837884,0.6442872091,11674.9386163883,-11146.9875339045,-33170.0808294557,11676.4346175714,-11147.2403968348,-33170.705539808,11676.508650735,-11145.9329728982,-33171.5951415381},{-353351.0098539133,577411.0799561687,3681.3728969291,-39.7185313461,-25.364881091,0.6757906594,-100761.0862591478,-25910.4807685804,-26456.0496246431,-100762.6129238349,-25910.615604427,-26456.323293119,-100760.6347238118,-25909.4802433226,-26457.5009741126},{-271381.5929719206,435945.4551194651,-1709.5837455916,-30.262414766,-18.783188782,-0.380475608,-30078.3807935398,68457.9906189913,11741.6553870559,-30078.1837707837,68457.8258806496,11741.0263336301,-30076.3413049331,68457.0110908337,11743.1169375811},{178157.1607408565,-282823.4726263193,3045.602292399,19.7561402121,12.0185410855,0.6442815654,11674.3083704443,-11145.298756346,-33170.3397816982,11675.8043937503,-11145.5516374969,-33170.9645084107,11675.8784837333,-11144.2442218845,-33171.8540583489}}

Covariance: BlockRealMatrix{{-1.4760798797,2.4113835304,0.0154567154,-2.3212489446,-1.4821320485,0.0403028212,-470.7200975611,-177.098057259,-32.0447843166,-470.7305011399,-177.0957776602,-32.0455932754,-470.7248803863,-177.0918284461,-32.053007081},{2.3791672772,-3.8872377427,-0.0253113507,3.7416562018,2.3896684851,-0.0661097443,761.3698494417,287.0041105545,57.1003382264,761.3865018007,287.0005107792,57.1017019672,761.3773148402,286.9939632508,57.1137515981},{-0.0032769972,0.0049769369,-0.0001866954,-0.0049822145,-0.0027999083,-0.00054232,0.3080091216,0.3231863453,3.0884459517,0.3079137425,0.3232393774,3.0884780964,0.3078508274,0.3231478233,3.0885119342},{-2.3065304543,3.7682802473,0.0243373051,-3.6272995374,-2.3163259867,0.0635135929,-736.8211981896,-277.4978389519,-52.5662748943,-736.8374030777,-277.4943096468,-52.5675667412,-736.8285622865,-277.4880539879,-52.5791996104},{-1.4403224027,2.3537073637,0.0155963122,-2.2653444115,-1.4472363676,0.0407985041,-462.6566504482,-174.7836336004,-38.3351175292,-462.6666500245,-174.7815087601,-38.3359828619,-462.6610001845,-174.7774219765,-38.3433438803},{-0.0128440806,0.0198878363,-0.0005011866,-0.0196972047,-0.0114827538,-0.0014247172,-0.3710343424,0.6514841967,8.6748217971,-0.3713259665,0.6516433662,8.6749050146,-0.3714883385,0.6513955473,8.6749846066},{-353.3297852434,577.3771635791,3.6816079417,-555.7480251237,-354.9102348439,9.4570404045,-100759.060032118,-25913.9120926468,-26458.5113807253,-100760.5866171936,-25914.0469413508,-26458.7850555403,-100758.6084874166,-25912.9114732647,-26459.9628694889},{-271.3827608084,435.947385028,-1.7095655272,-423.4635532233,-262.8341927457,-5.3239497369,-30078.3429801628,68458.3152992174,11740.8171000313,-30078.1459303948,68458.1505349215,11740.1880447592,-30076.3034361111,68457.3357584531,11742.2786610081},{178.1582396254,-282.8252828018,3.0455671763,276.4492168974,168.1764824625,9.0153354749,11674.2797800501,-11145.8264048908,-33169.1552652442,11675.7757606814,-11146.079252891,-33169.7799838361,11675.8498105024,-11144.7718593666,-33170.6695492631},{-353.3487856205,577.4077739934,3.6815467949,-555.777711504,-354.9287528032,9.4568270332,-100762.347680866,-25912.6137143457,-26457.3837131009,-100763.8743519174,-25912.7485492085,-26457.6573902145,-100761.8961505346,-25911.6131221314,-26458.8351580053},{-271.3781919151,435.9400970646,-1.7095048075,-423.4564470141,-262.8298368669,-5.323763913,-30078.1128689457,68457.9455033631,11740.4734532111,-30077.9157975201,68457.7807462542,11739.8443835932,-30076.0733144968,68456.9659930885,11741.9349743779},{178.163515699,-282.833712866,3.0456251371,276.4574282759,168.1815349688,9.0155052786,11674.9386163883,-11146.9875339045,-33170.0808294557,11676.4346175714,-11147.2403968348,-33170.705539808,11676.508650735,-11145.9329728982,-33171.5951415381},{-353.3510098539,577.4110799562,3.6813728969,-555.7810615341,-354.9305591291,9.456332783,-100761.0862591478,-25910.4807685804,-26456.0496246431,-100762.6129238349,-25910.615604427,-26456.323293119,-100760.6347238118,-25909.4802433226,-26457.5009741126},{-271.3815929719,435.9454551195,-1.7095837456,-423.461704983,-262.8329962483,-5.3239918536,-30078.3807935398,68457.9906189913,11741.6553870559,-30078.1837707837,68457.8258806496,11741.0263336301,-30076.3413049331,68457.0110908337,11743.1169375811},{178.1571607409,-282.8234726263,3.0456022924,276.447497094,168.1753402305,9.015426306,11674.3083704443,-11145.298756346,-33170.3397816982,11675.8043937503,-11145.5516374969,-33170.9645084107,11675.8784837333,-11144.2442218845,-33171.8540583489}}

Jacobian: BlockRealMatrix{{-8.8574164798,26.8455024046,-38.4519812392,0.0000993803,-0.0003012069,0.0004314318,6962.4696335735,-6118.4931637514,9411.1311329467,-6962.0730650858,6118.4624738251,-9411.4444578346,0.0,0.0,0.0},{-35.2533157379,67.6018485499,-7.6953936014,0.0003955427,-0.0007584937,0.0000863424,6962.4696338652,-6118.4931640078,9411.131133341,0.0,0.0,0.0,-6961.7813934183,6118.77670988,-9411.4559232347},{-9.0189342544,26.8209225418,-38.5161140417,-0.0772471355,0.2297117854,-0.3298794282,6956.6158978975,-6100.9878843818,9426.8114056966,-6956.2193857616,6100.9567596886,-9427.1241459774,0.0,0.0,0.0},{-35.7968161243,67.318100167,-7.7737469824,-0.3065918255,0.5765583631,-0.0665800028,6956.6158981889,-6100.9878846374,9426.8114060915,0.0,0.0,0.0,-6955.9276864186,6101.2712367968,-9427.1358591279},{-9.17905328,26.7941051789,-38.5769179317,-0.1573666166,0.4592891471,-0.6612825141,6950.7544377985,-6083.4906145333,9442.4300835715,-6950.3579833431,6083.4590561921,-9442.7422396843,0.0,0.0,0.0},{-36.3344934513,67.0255974578,-7.8511281622,-0.622860305,1.1489344627,-0.1345841264,6950.7544380896,-6083.4906147881,9442.430083967,0.0,0.0,0.0,-6950.0662578106,6083.7737727859,-9442.7542001107},{-9.337792552,26.7649903999,-38.6343748137,-0.2402495949,0.688396721,-0.9937413595,6944.8862062239,-6066.0025445644,9457.9860386245,-6944.4898110354,6065.970553626,-9458.2976109378,0.0,0.0,0.0},{-36.8664372367,66.7242833834,-7.9275255738,-0.9483185946,1.7162211261,-0.2039114211,6944.8862065146,-6066.0025448184,9457.9860390204,0.0,0.0,0.0,-6944.1980605372,6066.2855082422,-9458.3098182829},{-9.4951784983,26.7335473945,-38.6884686675,-0.3258867555,0.9169999544,-1.3272192018,6939.0121577241,-6048.524870097,9473.4781556516,-6938.6158233863,6048.492447659,-9473.789144591,0.0,0.0,0.0},....

J^TJ: BlockRealMatrix{{431548214.144989,309005956.87145466,34736537.076761976,-229216959.05954987,507234148.8498248,133064219.45603882,-3505929630.142931,4454911786.383659,-4862247604.472817,957174546.1709613,-1215205037.496732,1323879875.870447,2548394837.3464913,-3239802236.947285,3538540466.5330367},{309005956.87145466,238476353.54071522,27663997.743462976,-152155357.84583247,376957072.4818899,97825696.83452329,-2772119294.23997,3448405941.4777293,-3861559828.539818,791040998.8174201,-981126957.481105,1100092444.3109882,1980797103.1123986,-2467352983.3996196,2761603519.2734456},{34736537.076761976,27663997.743462976,3767917.4050263828,-15894586.700744953,42925479.10234587,11133409.779645937,-372582682.60591865,436231472.6913556,-529147604.21945673,110242449.55134119,-124950089.89366725,158437859.5254962,262303183.40119004,-311291111.6865493,370727743.0063601},{-229216959.05954987,-152155357.84583247,-15894586.700744953,135210813.8945289,-263219121.90614372,-69301745.5567023,1416328701.9183674,-2031885971.0825884,1874622899.6514692,-367207015.9691573,533666429.2015098,-480890080.69241434,-1048970387.3035146,1498258960.1567695,-1393804519.6286566},{507234148.8498248,376957072.4818899,42925479.10234587,-263219121.90614372,610132240.6630691,158852140.01272303,-4196608049.9119005,5390115581.6757345,-5773551918.770539,1175164413.996084,-1510818156.8834462,1611477641.9602919,3021013656.2703886,-3879410507.0996375,4162281823.8298197},{133064219.45603882,97825696.83452329,11133409.779645937,-69301745.5567023,158852140.01272303,41901856.16930937,-1118190197.9402385,1405095759.3232005,-1553084693.7671826,322505068.69516057,-379600546.4178778,458094547.1334755,795571365.3248297,-1025524663.7743595,1095044690.0606782},{-3505929630.142931,-2772119294.23997,-372582682.60591865,1416328701.9183674,-4196608049.9119005,-1118190197.9402385,57714555342.25803,-60573937567.00467,84578011002.89403,-28855438843.345776,30286760632.03137,-42290416081.28304,-28854083814.99954,30288132687.549805,-42290358193.73828},{4454911786.383659,3448405941.4777293,436231472.6913556,-2031885971.0825884,5390115581.6757345,1405095759.3232005,-60573937567.00467,68733524472.47699,-86551120479.26996,30285004418.73627,-34366560466.74142,43277102172.980934,30283561977.003937,-34367976774.24753,43276986997.24475},{-4862247604.472817,-3861559828.539818,-529147604.21945673,1874622899.6514692,-5773551918.770539,-1553084693.7671826,84578011002.89403,-86551120479.26996,125153999782.12097,-42286322397.20135,43275245351.869064,-62579040385.94828,-42284342762.13559,43277268935.995735,-62578978973.66154},{957174546.1709613,791040998.8174201,110242449.55134119,-367207015.9691573,1175164413.996084,322505068.69516057,-28855438843.345776,30285004418.73627,-42286322397.20135,28853600134.335423,-30284796281.488407,42287732887.89184,0.0,0.0,0.0},{-1215205037.496732,-981126957.481105,-124950089.89366725,533666429.2015098,-1510818156.8834462,-379600546.4178778,30286760632.03137,-34366560466.74142,43275245351.869064,-30284796281.488407,34366358700.1794,-43276787277.03587,0.0,0.0,0.0},{1323879875.870447,1100092444.3109882,158437859.5254962,-480890080.69241434,1611477641.9602919,458094547.1334755,-42290416081.28304,43277102172.980934,-62579040385.94828,42287732887.89184,-43276787277.03587,62581080953.55032,0.0,0.0,0.0},{2548394837.3464913,1980797103.1123986,262303183.40119004,-1048970387.3035146,3021013656.2703886,795571365.3248297,-28854083814.99954,30283561977.003937,-42284342762.13559,0.0,0.0,0.0,28850890312.723118,-30284725751.265636,42285695303.0202},{-3239802236.947285,-2467352983.3996196,-311291111.6865493,1498258960.1567695,-3879410507.0996375,-1025524663.7743595,30288132687.549805,-34367976774.24753,43277268935.995735,0.0,0.0,0.0,-30284725751.265636,34369191357.949936,-43278695746.55152},{3538540466.5330367,2761603519.2734456,370727743.0063601,-1393804519.6286566,4162281823.8298197,1095044690.0606782,-42290358193.73828,43276986997.24475,-62578978973.66154,0.0,0.0,0.0,42285695303.0202,-43278695746.55152,62580958117.39213}}

RMS: 1.0067571416874148

sigmas: {(NaN); (NaN); (NaN); (NaN); (NaN); (NaN); (NaN); 261,6453999198; (NaN); (NaN); 261,644378396; (NaN); (NaN); 261,6429075875; (NaN)}

Hi Antonio,

Some notes and questions about your matrices.

There seems to be 15 states estimated while there should be 12 I guess (orbit + 2 stations’ positions).
So you seem to estimate the position of the 3 stations instead of 2. Is that what you were looking for?
The thing with estimating all the parameters is that you could end up with an undetermined problem since your parameters are not independent anymore.
It is probably be what is happening there and that explains why trying to estimate everything fails.

The determinants of your covariances are very close to 0 (~1.e-54 for the physical version and ~1e-70 for the normalized version).
This comes from the matrix J^TJ whose determinant is around 1e+72.

So the J^TJ and thus the Jacobian J matrices seem to be ill conditioned.
Maybe this comes from the measurement model, or from Hipparchus/Orekit, I’m not sure.

That would definitely be helpful.
Also the initial orbit, the stations’ positions, the duration of the measurements arc and the time steps between measurements would be nice.

Just a side note but since 10.2 we use Gradient instead of DerivativeStructure in all measurements model; it is faster.

Hi Maxime,

Yes, it is. It is desirable to know the exact position of the three receivers.

You can find here the code of the measurement.

Why do you think it can be helpful? A priori, it should work whatever the orbit is and the antennas are if the baseline is not parallel to the arc, shouldn’t it?

Good point, ill change It in the future, thanks so much.

Hi Antonio,

I couldn’t download your file. I clicked on the “Request Access” button on google drive but nothing happened so far.

Yes indeed however it saves us the time to select which orbit, stations and links we’re going to use to reproduce the bug. But it is alright if we don’t have them.

Hi Maxime,

You are right, my bad. Can you try again? If you don’t visualize it try to download.

Hi Antonio,

I managed to download the file. But I don’t know when I will have time to look into it.

I’ve taken a look at your covariances again, and they really look badly conditionned.
The columns related to the X coordinate position of the stations (columns 7, 10 and 13) are almost identical.
Same goes for Y (columns, 8, 11 and 14) and Z (columns 9, 12, 15).
There seems to be some dependencies between your measurements that make the resolution of the system undoable.
I don’t know if this comes from the geometry of your problem (stations are too close from each other for example?) or from the fact that you seem to be using a common station for your two sets of TDOA measurements (break the independency of the measurements?)

Maxime

Hi Maxime,

I think it is the second thing you mention here. From output files when estimating position I have seen that the optimum is found for the same station geometry (ground stations relative position). Therefore, if both antenna positions can be estimated is like it can be found infinite configurations for the optimum