[Numpy-discussion] Does np.std() make two passes through the data?
Sun Nov 21 18:18:13 CST 2010
On Sun, Nov 21, 2010 at 6:43 PM, Keith Goodman <firstname.lastname@example.org> wrote:
> 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?
reference several times pointed to on the list is the wikipedia page, e.g.
I don't know about actual implementation.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion