[Numpy-discussion] efficient way to do this?
Fabrice Silva
silva@lma.cnrs-mrs...
Mon Sep 22 09:31:08 CDT 2008
Le lundi 22 septembre 2008 à 09:41 -0500, John Hunter a écrit :
> I have a an array of indices into a larger array where some condition
> is satisfied. I want to create a larger set of indices which *mark*
> all the indicies following the condition over some Nmark length
> window.
A = np.random.rand(N)
What about that:
marked = (A<0.01)
> In the real use case, there will be significant auto-correlation among
> the places where the condition is satisfied. Eg, if it is satisfied
> at some index, it is likely that it will be satisfied for many of its
> neighbors. Eg, the real case looks more like
>
> y = np.sin(2*np.pi*np.linspace(0, 2, N))
>
> ind = np.nonzero(y>0.95)[0]
> marked2 = np.zeros(N, bool)
> for i in ind:
> marked2[i:i+Nmark] = True
I do not understand what you do expect here to code...
--
Fabrice Silva <silva@lma.cnrs-mrs.fr>
LMA UPR CNRS 7051
More information about the Numpy-discussion
mailing list