mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-20 08:39:07 +08:00
welford mean: protect against negative variances
This commit is contained in:
parent
fbef296890
commit
dc7f29e2ec
@ -58,6 +58,9 @@ public:
|
||||
// M2 aggregates the squared distance from the mean
|
||||
// count aggregates the number of samples seen so far
|
||||
_M2 += delta.emult(new_value - _mean);
|
||||
|
||||
// protect against floating point precision causing negative variances
|
||||
_M2 = matrix::max(_M2, {});
|
||||
}
|
||||
|
||||
bool valid() const { return _count > 2; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user