Re: [Numpy-discussion] in place random generation

2007-03-10 Thread Mark P. Miller
would allow Scipy to have a pure random number generator, whereas numpy could keep its fancier (but slower) array-based random number generators. Robert Kern wrote: > Anne Archibald wrote: >> On 09/03/07, Robert Kern <[EMAIL PROTECTED]> wrote: >>> Mark P. Miller wrote: &

Re: [Numpy-discussion] in place random generation

2007-03-09 Thread Mark P. Miller
Robert Kern wrote: > scipy.random is not a package. scipy/__init__.py does a "from numpy import *" > and thus pulls in numpy.random. > Got it...and one more question: What about using something like from numpy.random import mtrand And then using mtrand.seed and mtrand.normal in code? Would

Re: [Numpy-discussion] in place random generation

2007-03-09 Thread Mark P. Miller
This discussion has much in common with a previous thread that I started ("When and where to use Numpy..."). I fully admit to being a naive numpy user, but it seems to me that it would be helpful if the documentation provided some explicit statements to inform potential users about the best typ

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-06 Thread Mark P. Miller
Charles R Harris wrote: > I won't comment on the code itself. Tell us what you want to do and I > bet we can speed it up. > Here's a bit of sample code. It's actually very useful for my purposes. Are there good ways to express these ideas in numpy as opposed to using all of the nested loop

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-02 Thread Mark P. Miller
> > I won't comment on the code itself. Appreciate it :). Again, I'm just pointing out an example! I would guess that I'm not the only person using numpy in this sort of unsophisticated manner! Tell us what you want to do and I > bet we can speed it up. > > Chuck I'll probably do that in

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
array1[aa,bb]=array1[x1,x2] >>> import timeit >>> t=timeit.Timer("numpytest()", "from __main__ import numpytest") >>> t.timeit(100) 17.143569084897678 >>> t.timeit(100) 17.183305140737161 >>> t.timeit(100) 17.283449432818969 >

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
One more note (this perhaps may need a separate topic): I've been using the Enthought python edition that contains python 2.4.3 and numpy 0.9.9.2706. After Robert Kern pointed out that I should try numpy 1.0.1, I went ahead and installed it (downloaded a few hours ago: "numpy-1.0.1.win32-py2.4

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
>> > > Ops, this seems a bug with your numpy version: > > In [46]:array1 = numpy.zeros((10,10),int) > In [47]:array1.itemset((5,5),9) > In [48]:array1 > Out[48]: > array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >[0,

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
> try with > array1.itemset((5,5),9) Yep...tried that. But I don't get it! >>> import numpy >>> array1 = numpy.zeros((10,10),int) >>> array1 array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) -Mark (now using 1.0.1) Robert Kern wrote: > Mark P. Miller wrote: >> Travis: Can you clarify this for me. The book doesn't have much detail >> here and seems to differ from your

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
Travis: Can you clarify this for me. The book doesn't have much detail here and seems to differ from your notation (which gives me errors). >> Getting single indices like this is a bit slower for NumPy then for >> lists because of all the possibilities that must be distinguished for >> array

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
>> ##imports >> import numpy as NP >>from numpy.random import randint >> #numpy array code >> array1 = NP.zeros((50,50), int) >> >> def random1(): >> c = array1(randint(10), randint(10)) >> >> > Is this a bug? You can't "call" an array. Did you mean, > array1[randint(10), randint(10)]?

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
eit.Timer("random2()", "from __main__ import random2") >>> t.timeit(1) 0.24217882440370886 >>> t.timeit(1) 0.077239146316060214 >>> t.timeit(1) 0.07531906988197079 >>> t.timeit(1) 0.075705711200498627 -Mark Perry Green

[Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
I've been using Numpy arrays for some work recently. Just for fun, I compared some "representative" code using Numpy arrays and an object comprised of nested lists to represent my arrays. To my surprise, the array of nested lists outperformed Numpy in this particular application (in my actual

Re: [Numpy-discussion] python's random.random() fas ter than numpy.random.rand() ???

2007-01-29 Thread Mark P Miller
Sorry...this somehow ended up in the wrong place. Apologies...I'm still getting a feel for how this query system works! ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] python's random.random() faster than numpy.random.rand() ???

2007-01-29 Thread Mark P. Miller
es of what I was trying to convey though. Does that particular bit of code require optimization? Thanks, -Mark -- Dr. Mark P. Miller Department of Biology 5305 Old Main Hill Utah State University Logan, UT 84322-5305 USA ><><><><><><><>&

[Numpy-discussion] python's random.random() faster than numpy.random.rand() ???

2007-01-27 Thread Mark P. Miller
should I be using some other approach to call numpy's uniform generator? -Mark -- Dr. Mark P. Miller Department of Biology 5305 Old Main Hill Utah State University Logan, UT 84322-5305 USA ><><><><><><><><><><><><>