mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 10:26:52 +08:00
WelfordMean: remove unnecessary case for first sample
setting the mean to the sample value and then adding 0 is the same as setting the mean to zero and then add the sample value divided by 1
This commit is contained in:
@@ -49,10 +49,6 @@ public:
|
|||||||
// For a new value, compute the new count, new mean, the new M2.
|
// For a new value, compute the new count, new mean, the new M2.
|
||||||
void update(const T &new_value)
|
void update(const T &new_value)
|
||||||
{
|
{
|
||||||
if (_count == 0) {
|
|
||||||
_mean = new_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
_count++;
|
_count++;
|
||||||
|
|
||||||
// mean accumulates the mean of the entire dataset
|
// mean accumulates the mean of the entire dataset
|
||||||
|
|||||||
Reference in New Issue
Block a user