[Numpy-discussion] Quick Question about Optimization

James Snyder jbsnyder@gmail....
Mon May 19 18:30:41 CDT 2008


Separating the response into 2 emails, here's the aspect that comes
from implementations of random:

In short, that's part of the difference. I ran these a few times to
check for consistency.

MATLAB (R2008a:
tic
for i = 1:2000
    a = randn(1,13857);
end
toc

Runtime: ~0.733489 s

NumPy (1.1.0rc1):
import numpy as np
import time

t1 = time.time()
for n in xrange(0,2000):
    a = np.random.standard_normal(size=(1,14000))
t2 = time.time()

print 'Runtime: %1.3f s' % ((t2-t1))

Runtime: ~2.716 s

On Mon, May 19, 2008 at 3:53 PM, Christopher Barker
<Chris.Barker@noaa.gov> wrote:
> Anne Archibald wrote:
>> 2008/5/19 James Snyder <jbsnyder@gmail.com>:
>>> I can provide the rest of the code if needed, but it's basically just
>>> filling some vectors with random and empty data and initializing a few
>>> things.
>>
>> It would kind of help, since it would make it clearer what's a scalar
>> and what's an array, and what the dimensions of the various arrays
>> are.
>
> It would also help if you provided a complete example (as little code as
> possible), so we could try out and time our ideas before suggesting them.
>
>>> np.random.standard_normal(size=(1,self.naff))
>
> Anyone know how fast this is compared to Matlab? That could be the
> difference right there.
>
> -Chris
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker@noaa.gov
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
James Snyder
Biomedical Engineering
Northwestern University
jbsnyder@gmail.com


More information about the Numpy-discussion mailing list