Jeff Aa wrote at Thu, 19 Sep 2002 19:08:44 +0200:

>> I liked your algorithm as it is quick and easy.
>> But on the other hand the results aren't as good as possible.
> 
> Actually, I do believe that the results are as good as possible, for any
> distribution of numbers. 8-) consider that the first pass creates the
> best possible approximation available by pairing the min and max. The
> second pass merges the remaining values into the approximations, by
> processing both the approximations and remaining numbers in sorted order
> - ergo, it will produce the best possible result, irrespective of the
> distribution of numbers.

Let's take an easy example: Numbers
1  8  27  64  125  216  343  512  729

Your algorithm will first group the mins/max =>
( 1 729)
( 8 512)
(27 343)

and then assign the remaining numbers, so that the final result is
( 1  64 729)  (avg 264,67)
( 8 125 512)  (avg 215)
(27 216 343)  (avg 195,33)

while the script I posted prints
1 8 729 avg 246
27 125 512 avg 221.333333333333
64 216 343 avg 207.666666666667

what seems to be really a bit better


Greetings,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to