That seems to do the trick. Runtimes are reduced by 15-20% in my code.
Robert Kern wrote:
> The reason is that tmp1 is no longer a mask into RNDarray, but into
> RNDarray[tmp1] (the old tmp1). For something as small as (50, 50) and simple
> criteria (no looping), the first version will probably
On 07/07/07, Mark.Miller <[EMAIL PROTECTED]> wrote:
> A quick question for the group. I'm working with some code to generate
> some arrays of random numbers. The random numbers, however, need to
> meet certain criteria. So for the moment, I have things that look like
> this (code is just an abst
Mark.Miller wrote:
> Sorry...here's a minor correction to the code.
>
> #1st part
> import numpy
> normal=numpy.random.normal
>
> RNDarray = normal(25,15,(50,50))
> tmp1 = (RNDarray < 0) | (RNDarray > 25)
> while tmp1.any():
> print tmp1.size, tmp1.shape, tmp1[tmp1].size
> RNDarray[tmp1
Sorry...here's a minor correction to the code.
#1st part
import numpy
normal=numpy.random.normal
RNDarray = normal(25,15,(50,50))
tmp1 = (RNDarray < 0) | (RNDarray > 25)
while tmp1.any():
print tmp1.size, tmp1.shape, tmp1[tmp1].size
RNDarray[tmp1] = normal(25,15, size = RNDarray[tmp1].s
A quick question for the group. I'm working with some code to generate
some arrays of random numbers. The random numbers, however, need to
meet certain criteria. So for the moment, I have things that look like
this (code is just an abstraction):
import numpy
normal=numpy.random.normal
RNDar