Re: [Numpy-discussion] hairy optimization problem

2009-05-07 Thread Sebastian Walter
hi mathew, 1) what does it mean if a value is None? I.e., what is larger: None or 3? Then first thing I would do is convert the None to a number. 2) Are your arrays integer arrays or double arrays? It's much easier if they are doubles because then you could use standard methods for NLP problems,

Re: [Numpy-discussion] efficient 3d histogram creation

2009-05-07 Thread Stéfan van der Walt
2009/5/7 Chris Colbert sccolb...@gmail.com: This was really my first attempt at doing anything constructive with Cython. It was actually unbelievably easy to work with. I think i spent less time working on this, than I did trying to find an optimized solution using pure numpy and python. One

Re: [Numpy-discussion] efficient 3d histogram creation

2009-05-07 Thread Dag Sverre Seljebotn
Dag Sverre Seljebotn wrote: Stéfan van der Walt wrote: 2009/5/7 Chris Colbert sccolb...@gmail.com: This was really my first attempt at doing anything constructive with Cython. It was actually unbelievably easy to work with. I think i spent less time working on this, than I did trying to find

Re: [Numpy-discussion] hairy optimization problem

2009-05-07 Thread Mathew Yeates
David Huard wrote: Hi Mathew, You could use Newton's method to optimize for each vi sequentially. If you have an expression for the jacobian, it's even better. Here's the problem. Every time f is evaluated, it returns a set of values. (a row in the matrix) But if we are trying to find the

Re: [Numpy-discussion] hairy optimization problem

2009-05-07 Thread Mathew Yeates
Sebastian Walter wrote: N optimization problems. This is very unusual! Typically the problem at hand can be formulated as *one* optimization problem. yes, this is really not so much an optimization problem as it is a vectorization problem. I am trying to avoid 1) Evaluate f over and over

Re: [Numpy-discussion] hairy optimization problem

2009-05-07 Thread Mathew Yeates
Thanks Ken, I was actually thinking about using caching while on my way into work. Might work. Beats the heck out of using brute force. One other question (maybe I should ask in another thread) what is the canonical method for dealing with missing values? Suppose f(x,y) returns None for some

[Numpy-discussion] optimization when there are mssing values

2009-05-07 Thread Mathew Yeates
What is the canonical method for dealing with missing values? Suppose f(x,y) returns None for some (x,y) pairs (unknown until evaluation). I don't like the idea of setting the return to some small value as this may create local maxima in the solution space. So any of the scipy packages deal

[Numpy-discussion] element wise help

2009-05-07 Thread Chris Colbert
suppose i have two arrays: n and t, both are 1-D arrays. for each value in t, I need to use it to perform an element wise scalar operation on every value in n and then sum the results into a single scalar to be stored in the output array. Is there any way to do this without the for loop like

Re: [Numpy-discussion] element wise help

2009-05-07 Thread Chris Colbert
unfortunately, the actual function being processes is not so simple, and involves evaluating user functions input from the prompt as strings. So i have no idea how to do it in Cython. Let me look into this broadcasting. Thanks Josef! On Thu, May 7, 2009 at 12:56 PM, josef.p...@gmail.com wrote:

Re: [Numpy-discussion] element wise help

2009-05-07 Thread Chris Colbert
let me just post my code: t is the time array and n is also an array. For every value of time t, these operations are performed on the entire array n. Then, n is summed to a scalar which represents the system response at time t. I would like to eliminate this for loop if possible. Chris

Re: [Numpy-discussion] element wise help

2009-05-07 Thread josef . pktd
On Thu, May 7, 2009 at 1:08 PM, Chris Colbert sccolb...@gmail.com wrote: let me just post my code: t is the time array and n is also an array. For every value of time t, these operations are performed on the entire array n. Then, n is summed to a scalar which represents the system response

Re: [Numpy-discussion] element wise help

2009-05-07 Thread Chris Colbert
its part of a larger program for designing PID controllers. This particular function numerical calculates the inverse laplace transform using riemann sums. The exec statements, from what i gather, allow the follow eval statement to be executed in the scope of numpy and its functions. I don't get

[Numpy-discussion] FYI: Numpy and Unladen Swallow

2009-05-07 Thread Bruce Southey
Hi, LWN.net had a article on the development of Unladen Swallow that aims to speed up CPython. http://lwn.net/SubscriberLink/332038/675304c610f0e34a/ The project link is: http://code.google.com/p/unladen-swallow/ At least on my Linux system, Numpy does run without any test failures. It appears

Re: [Numpy-discussion] element wise help

2009-05-07 Thread josef . pktd
On Thu, May 7, 2009 at 2:11 PM, Chris Colbert sccolb...@gmail.com wrote: alright I got it working. Thanks! This version is an astonishingly 1900x faster than my original implementation which had two for loops. Both versions are below: thanks again! ### new fast code     b = 4.7    

Re: [Numpy-discussion] element wise help

2009-05-07 Thread Chris Colbert
the user of the program inputs the transform in a text field. So I have no way of know the function apriori. that doesn't mean I still couldn't throw the exec and eval commands into another function just to clean things up. Chris On Thu, May 7, 2009 at 2:45 PM, josef.p...@gmail.com wrote: On

Re: [Numpy-discussion] element wise help

2009-05-07 Thread josef . pktd
On Thu, May 7, 2009 at 3:10 PM, Chris Colbert sccolb...@gmail.com wrote: the user of the program inputs the transform in a text field. So I have no way of know the function apriori. that doesn't mean I still couldn't throw the exec and eval commands into another function just to clean things

Re: [Numpy-discussion] element wise help

2009-05-07 Thread josef . pktd
On Thu, May 7, 2009 at 3:39 PM, josef.p...@gmail.com wrote: On Thu, May 7, 2009 at 3:10 PM, Chris Colbert sccolb...@gmail.com wrote: the user of the program inputs the transform in a text field. So I have no way of know the function apriori. that doesn't mean I still couldn't throw the exec

Re: [Numpy-discussion] element wise help

2009-05-07 Thread Chris Colbert
that's essentially what the eval statement does. On Thu, May 7, 2009 at 4:22 PM, josef.p...@gmail.com wrote: On Thu, May 7, 2009 at 3:39 PM, josef.p...@gmail.com wrote: On Thu, May 7, 2009 at 3:10 PM, Chris Colbert sccolb...@gmail.com wrote: the user of the program inputs the transform in

Re: [Numpy-discussion] efficient 3d histogram creation

2009-05-07 Thread Charles R Harris
2009/5/7 Dag Sverre Seljebotn da...@student.matnat.uio.no Stéfan van der Walt wrote: 2009/5/7 Chris Colbert sccolb...@gmail.com: This was really my first attempt at doing anything constructive with Cython. It was actually unbelievably easy to work with. I think i spent less time

Re: [Numpy-discussion] efficient 3d histogram creation

2009-05-07 Thread Chris Colbert
after looking at it for a while, I don't see a way to easily speed it up using pure numpy. As a matter of fact, the behavior shown below is a little confusing. Using fancy indexing, multiples of the same index are interpreted as a single call to that index, probably this a for a reason that I

[Numpy-discussion] replacing Nan's in a string array converted from a float array

2009-05-07 Thread Brennan Williams
I've created an array of strings using something like stringarray=self.karray.astype(|S8) If the array value is a Nan I get 1.#QNAN in my string array. For cosmetic reasons I'd like to change this to something else, e.g. invalid or inactive. My string array can be up to

Re: [Numpy-discussion] replacing Nan's in a string array converted from a float array

2009-05-07 Thread Robert Kern
On Thu, May 7, 2009 at 19:36, Brennan Williams brennan.willi...@visualreservoir.com wrote: I've created an array of strings using something like              stringarray=self.karray.astype(|S8) If the array value is a Nan I get 1.#QNAN in my string array. For cosmetic reasons I'd like

Re: [Numpy-discussion] replacing Nan's in a string array converted from a float array

2009-05-07 Thread Charles R Harris
On Thu, May 7, 2009 at 5:36 PM, Brennan Williams brennan.willi...@visualreservoir.com wrote: I've created an array of strings using something like stringarray=self.karray.astype(|S8) If the array value is a Nan I get 1.#QNAN in my string array. For cosmetic reasons I'd

Re: [Numpy-discussion] replacing Nan's in a string array converted from a float array

2009-05-07 Thread Brennan Williams
Charles R Harris wrote: On Thu, May 7, 2009 at 5:36 PM, Brennan Williams brennan.willi...@visualreservoir.com mailto:brennan.willi...@visualreservoir.com wrote: I've created an array of strings using something like stringarray=self.karray.astype(|S8) If