On Fri, Sep 26, 2008 at 7:22 AM, David Di Biase <dave.dibiase@g mail.comwrote:
Uh, this part of your sentence doesn't quite make sense...
Well, unless you're going to use the rest of the sorted values at some
point in your program and since you have a large quantity of data,
yes, my way ought to be faster. Sorting the list is O(N*log(N)) while
running max and min over the list is only O(N).
Regards,
Chris
--
Follow the path of the Iguana...
Hi Chris,
>
Yeah I hear you on point A. but this the specification I was given, so I
have to follow it unfortunately. I've also been restricted and not allowed
to use any other packages. I was using NumPy earlier (should have mentioned
that) but I was wondering if there was a simpler way. Is NumPy technically
even faster than just iterating and modifying the list directly?
>
Also if I'm creating an array then making it,
>
Yeah I hear you on point A. but this the specification I was given, so I
have to follow it unfortunately. I've also been restricted and not allowed
to use any other packages. I was using NumPy earlier (should have mentioned
that) but I was wondering if there was a simpler way. Is NumPy technically
even faster than just iterating and modifying the list directly?
>
Also if I'm creating an array then making it,
why not just do a temporary
sort and capture the first and last values? Is this method you've provided
supposed to be faster?
sort and capture the first and last values? Is this method you've provided
supposed to be faster?
point in your program and since you have a large quantity of data,
yes, my way ought to be faster. Sorting the list is O(N*log(N)) while
running max and min over the list is only O(N).
Regards,
Chris
>
Dave
>
On Fri, Sep 26, 2008 at 12:42 AM, Chris Rebert <clp@rebertia.c omwrote:
>
>
Dave
>
On Fri, Sep 26, 2008 at 12:42 AM, Chris Rebert <clp@rebertia.c omwrote:
>>
>On Thu, Sep 25, 2008 at 8:57 PM, David Di Biase <dave.dibiase@g mail.com>
>wrote:
>>
>A. You should probably be using objects rather than arrays to
>represent your datapoints, so that they're more structured and it's
>more apparent what the values mean.
>>
>B. Assuming by "distance" you meant "difference " and/or that the
>distance is only in 1 dimension:
>>
>from operator import itemgetter
>firsts = map(itemgetter( 0), main_list)
>distance = max(firsts) - min(firsts)
>>
>>
>You just have to apply the transform to each list element individually
>(also, you might consider using NumPy [http://numpy.scipy.org/] if
>you're doing a lot of matrix manipulation):
>>
>for lst in main_list:
> lst[0] *= some_value
>>
>Regards,
>Chris
>>
>--
>Follow the path of the Iguana...
>http://rebertia.com
>On Thu, Sep 25, 2008 at 8:57 PM, David Di Biase <dave.dibiase@g mail.com>
>wrote:
I have a list with about 1000-1500 sub-lists which look like so:
list[-0.2881795521329 0786, 3.6693631467403 929, 'H', 31.312252330357 84]]
>
The first and second values are Angstrom units specifying the location
of a
particle. What I'd like to do is determine the distance between the
smallest
and largest value in the arrays first position 0. I tried reading the
manual
for this but I don't see how it applies key or any of those other
commands
to the function. I could easily write a sort to do this and capture the
first and last spots, but why do that when I can use max and min (if I
can
actually do that...).
list[-0.2881795521329 0786, 3.6693631467403 929, 'H', 31.312252330357 84]]
>
The first and second values are Angstrom units specifying the location
of a
particle. What I'd like to do is determine the distance between the
smallest
and largest value in the arrays first position 0. I tried reading the
manual
for this but I don't see how it applies key or any of those other
commands
to the function. I could easily write a sort to do this and capture the
first and last spots, but why do that when I can use max and min (if I
can
actually do that...).
>A. You should probably be using objects rather than arrays to
>represent your datapoints, so that they're more structured and it's
>more apparent what the values mean.
>>
>B. Assuming by "distance" you meant "difference " and/or that the
>distance is only in 1 dimension:
>>
>from operator import itemgetter
>firsts = map(itemgetter( 0), main_list)
>distance = max(firsts) - min(firsts)
>>
>
So you wonderful Python gods, lay some knowledge on me. please? lol...
>
while I'm at it, is there a way to modify an entire list without having
to
produce a whole new one? For example now say I want to modify list[0]
and
multiply it by some value. From what I understand previous version of
Python
allowed lists to be multiplied like matrices...now apparently it just
replicates the list. :-/ shucks...
So you wonderful Python gods, lay some knowledge on me. please? lol...
>
while I'm at it, is there a way to modify an entire list without having
to
produce a whole new one? For example now say I want to modify list[0]
and
multiply it by some value. From what I understand previous version of
Python
allowed lists to be multiplied like matrices...now apparently it just
replicates the list. :-/ shucks...
>You just have to apply the transform to each list element individually
>(also, you might consider using NumPy [http://numpy.scipy.org/] if
>you're doing a lot of matrix manipulation):
>>
>for lst in main_list:
> lst[0] *= some_value
>>
>Regards,
>Chris
>>
>Follow the path of the Iguana...
>http://rebertia.com
>
--
Follow the path of the Iguana...