Open
Description
NumPy may give a nonzero variance (and thus standard deviation) for a constant array. This may be due to loss of numerical precision, but Pythons builtin variance routine gives the correct 0 answer, so clearly it's a preventable loss:
In [45]: x = [6715266981.538051]*10
In [46]: statistics.variance(x)
Out[46]: 0.0
In [47]: numpy.array(x).var()
Out[47]: 9.0949470177292824e-13
I think it would be highly desirable if x.std()
and x.var()
for a constant array could be assumed to be exactly identical to zero. I'm aware one should not compare floating point numbers but zero is a bit of a special case.
Metadata
Metadata
Assignees
Labels
No labels