[Numpy-discussion] np.var() and ddof

josef.pktd@gmai... josef.pktd@gmai...
Fri Dec 10 16:26:54 CST 2010


On Fri, Dec 10, 2010 at 4:42 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
> Why does ddof=2 and ddof=3 give the same result?
>
>>> np.var([1, 2, 3], ddof=0)
>   0.66666666666666663
>>> np.var([1, 2, 3], ddof=1)
>   1.0
>>> np.var([1, 2, 3], ddof=2)
>   2.0
>>> np.var([1, 2, 3], ddof=3)
>   2.0
>>> np.var([1, 2, 3], ddof=4)
>   -2.0
>
> I expected NaN for ddof=3.

It's a floating point calculation, so I would expect np.inf

Josef

> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list