[Numpy-discussion] in place random generation
Daniel Mahler
dmahler at gmail.com
Thu Mar 8 10:37:03 EST 2007
On 3/8/07, Charles R Harris <charlesr.harris at gmail.com> wrote:
> The slow down is probably related to this from a previous thread:
>
> In [46]: def test1() :
> ....: x = normal(0,1,1000)
> ....:
>
> In [47]: def test2() :
> ....: for i in range(1000) :
> ....: x = normal(0,1)
>
> In [50]: t = timeit.Timer('test1()', "from __main__ import test1, normal")
>
> In [51]: t.timeit(100)
> Out[51]: 0.022681951522827148
>
> In [52]: t = timeit.Timer('test2()', "from __main__ import test2, normal")
>
> In [53]: t.timeit(100)
> Out[53]: 4.3481810092926025
Yes, that is the kind of test that prompted my post in the first place.
> Robert thought this might relate to Travis' changes adding broadcasting to
> the random number generator. It does seem certain that generating small
> arrays of random numbers has a very high overhead.
Does that mean someone is working on fixing this?
Also what does 'adding broadcasting to the number generator' mean?
The random generators currently do not take arrays as args,
so I am not sure what it would mean with the current interface.
Something like normal(0,1,target=A) though would be what I was asking
about in originally,
but it seems like this is the cause of my problem rather that the solution :(.
thanks
D
> Chuck
>
More information about the NumPy-Discussion
mailing list