[Numpy-discussion] performance issue (again)

Keith Goodman kwgoodman at gmail.com
Tue Apr 21 19:04:20 EDT 2009


On 4/21/09, josef.pktd at gmail.com <josef.pktd at gmail.com> wrote:
> On Tue, Apr 21, 2009 at 6:23 PM, Keith Goodman <kwgoodman at gmail.com> wrote:
>
>> On 4/21/09, Mathew Yeates <myeates at jpl.nasa.gov> wrote:
>> > Hi
>> > I posted something about this earlier
>> >
>> > Say I have 2 arrays X and Y with shapes (N,3) where N is large
>> > I am doing the following
>> >
>> > for row in range(N):
>> >     result=polyfit(X[row,:],Y[row,:],1,full=True) # fit 3 points with a
>> line
>> >
>> > This takes forever and I was hoping to find a way to speed things up.
>> > But now I'm starting to wonder if this pointless. If the routine "poly
>> > fit takes a  long time, when compared with the time for a Python
>> > function call, then things can't be sped up.
>> >
>> > Any comments?
>>
>> If you remove the mean from x and y (along axis = 1) then can't you
>> just do something like
>>
>> (x*y).sum(1) / (x*x).sum(axis=1)
>>
>
> I think that's what I said 8 days ago.

Nice. You even calculated the intercepts.



More information about the NumPy-Discussion mailing list