Re: Lists: Converting Double to Single

2007-03-02 Thread Duncan Booth
Jussi Salmela <[EMAIL PROTECTED]> wrote: > I've run a couple of tests and it seems to me that Dennis Lee Bieber is > on the trail of the truth when he claims that smallest magnitude to > the largest is the way to do the summation. Actually it isn't THE way > although it diminishes the error.

Re: Lists: Converting Double to Single

2007-03-01 Thread Jussi Salmela
Duncan Booth kirjoitti: > Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > >> For floating point, smallest magnitude to largest IS the most >> precise. >> >> Pretend you only have 2 significant digits of precision... >> >> 10 + 0.4 + 0.4 + 0.4 => 10 >> >> 0.4 + 0.4 + 0.4 + 10 =>

Re: Lists: Converting Double to Single

2007-02-28 Thread Duncan Booth
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > For floating point, smallest magnitude to largest IS the most > precise. > > Pretend you only have 2 significant digits of precision... > > 10 + 0.4 + 0.4 + 0.4 => 10 > > 0.4 + 0.4 + 0.4 + 10 => 11 and if you try the way I sugg

Re: Lists: Converting Double to Single

2007-02-27 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > If the values vary greatly in magnitude, you probably want to add them > from smallest to biggest; other than that, how else can you calculate the > mean? > It doesn't have to be smallest to largest, but the important thing is not to be adding the mil

Re: Lists: Converting Double to Single

2007-02-27 Thread Neil Cerutti
On 2007-02-27, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 27 Feb 2007 10:06:29 +, Duncan Booth wrote: >> Adding up a long list of values and then dividing by the >> number of values is the classic computer science example of >> how to get an inaccurate answer from a floating point >>

Re: Lists: Converting Double to Single

2007-02-27 Thread Steven D'Aprano
On Tue, 27 Feb 2007 10:06:29 +, Duncan Booth wrote: > Adding up a long list of values > and then dividing by the number of values is the classic computer > science example of how to get an inaccurate answer from a floating point > calculation. I'm not entirely ignorant when it comes to com

Re: Lists: Converting Double to Single

2007-02-27 Thread Duncan Booth
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > Something like (pseudo-code): > > > cnt = 0 > for rw in cursor(): > if cnt: > for i,v in enumerate(rw): >sum[i] += v #accumulate next row > else: > sum = rw #initialize to first row >

Re: Lists: Converting Double to Single

2007-02-26 Thread Scott David Daniels
Leif K-Brooks wrote: > [EMAIL PROTECTED] wrote: >> ... >> Unfortunately, when I try to use that last list in a NumPy function, >> I'm told that it cannot be broadcast to the correct shape. So, what I >> want to do is strip the extra brackes from each end to leave just >> [3.5, 4.5, 5.5, 6.5, 7.5].

Re: Lists: Converting Double to Single

2007-02-26 Thread rshepard
On 2007-02-27, Leif K-Brooks <[EMAIL PROTECTED]> wrote: Lief, Bjoern: > l = l[0] Of course! If I had let it work in my mind overnight I would almost certainly have seen this. Thank you both for your patient responses, Rich -- http://mail.python.org/mailman/listinfo/python-list

Re: Lists: Converting Double to Single

2007-02-26 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > I end up with a single list, but with two brackets on each end, > for example, [[3.5, 4.5, 5.5, 6.5, 7.5]]. > > Unfortunately, when I try to use that last list in a NumPy > function, I'm > told that it cannot be broadcast to the correct shape. So, what I > want to d

Re: Lists: Converting Double to Single

2007-02-26 Thread Leif K-Brooks
[EMAIL PROTECTED] wrote: > So I have lists that look like this: [1, 2, 3, 4, 5]. When I > concatenate lists, I end up with a list of lists that looks like > this: [[1, 2, 3. 4, 5]. [6, 7. 8, 9. 10]]. Really? >>> [1, 2, 3, 4, 5] + [6, 7, 8, 9, 10] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > Then, I aver

Lists: Converting Double to Single

2007-02-26 Thread rshepard
I start with a list of tuples retrieved from a database table. These tuples are extracted and put into individual lists. So I have lists that look like this: [1, 2, 3, 4, 5]. When I concatenate lists, I end up with a list of lists that looks like this: [[1, 2, 3. 4, 5]. [6, 7. 8, 9. 10]]. Then, I