[SciPy-User] scipy.stats.nanstd, bias and ddof

Keith Goodman kwgoodman@gmail....
Fri Jan 15 12:07:28 CST 2010

By default np.std and scipy.std normalize by N. But scipy.stats.nanstd
normalizes by N-1.

>> x = np.random.rand(4)
>> np.std(x)
>> scipy.std(x)
>> scipy.stats.nanstd(x)
>> scipy.stats.nanstd(x, bias=True)

Can the default for nanstd be changed to bias=True? Or would that break code?

Even better I guess would be to replace the bias keyword with ddof as
used in np.std and scipy.std. So

    if bias:
        m2c = m2 / n
        m2c = m2 / (n - 1.)

in scipy.stats.nanstd would become

     m2c = m2 / (n - ddof)

For me it doesn't matter if the default ddof is 0 or 1. But it is nice
when all std functions use the same default.

More information about the SciPy-User mailing list