Closed etiennedemontalivet closed 5 years ago
I would propose to compute variance and standard deviation always using numElement
instead of numElement - 1
Attached are associated patches for variance and standard deviation, only for f32 format.
@etiennedemontalivet We have plan to rework those functions because they are not using the best algorithms in term of numerical stability.
The numElement - 1 is normal otherwise the estimator of the variance is biased.
You can look at the "Two-pass algorithm" here https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
Now the bias is not the only important factor for an estimator. So, this function may not match all the needs.
Thanks for pointing that out.
File Path: CMSIS_5/CMSIS/DSP/Source/StatisticsFunctions/arm_var_f32.c
I have just tested the ouptut of _arm_varf32. As detailed in the doc, it uses the algorithm :
Result = sum(element - meanOfElements)^2) / numElement - 1
Should'nt it be instead :Result = sum(element - meanOfElements)^2) / numElement
Same for the standard deviation ?