[Numpy-discussion] Does np.std() make two passes through the data?
Sun Nov 21 17:43:12 CST 2010
Does np.std() make two passes through the data?
>> arr = np.random.rand(10)
Looks like an algorithm that makes one pass through the data (one for
loop) wouldn't match arr.std():
>> np.sqrt((arr*arr).mean() - arr.mean()**2)
But a slower two-pass algorithm would match arr.std():
>> np.sqrt(((arr - arr.mean())**2).mean())
Is there a way to get the same result as arr.std() in one pass (cython
for loop) of the data?
More information about the NumPy-Discussion