3 ms·
I may be missing something, but since the error accumulation variable "c" is also of finite width, isn't this the same as simply computing your sums in double p
by wiml 11y ago
I may be missing something, but since the error accumulation variable "c" is also of finite width, isn't this the same as simply computing your sums in double precision and then truncating? A pessimal input can still cause cancellation in both sum and c and leave you with an arbitrarily large error.
- alexSanchStern 11y agoYes, that's completely true. But while there are still inputs for which terrible accuracy could result, for many of the inputs which would arise in practice, the Kahan summation technique is "good enough" to prevent loss of accuracy. The chances of getting an input for which catastrophic cancellation would result on the doubled precision are far overshadowed by the chances of getting inputs for which the normal summation would have unacceptable loss accuracy, but Kahan summation would not.
- benjaminl 11y agoThat is what I was thinking the whole article. Seem like not only would that be simpler it would also be faster. I assume that there is a reason for employing this, but I couldn't find it. Looking at the paper A Comparison of Method For accurate Summation by McNamee[1], double precision beats Kahan summation, both in speed and reduction in errors. Moving to double precision of course only holds if your variables were previously only single precision. If your variables are already double precision, I could see the reason for implementing more exotic methods. [1] http://www.sigsam.org/bulletin/articles/147/sumnums.pdf http://www.sigsam.org/bulletin/articles/147/sumnums.pdf