Talk:Averages/Simple moving average: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎Numerical soundness: interesting but)
Line 4: Line 4:


:Hmm, and wouldn't it potentially loose less precision if you sorted on absolute values and summed from the smallest absolute value up? We could hope that people read the talk page before using code snippets? --[[User:Paddy3118|Paddy3118]] 16:07, 20 June 2009 (UTC)
:Hmm, and wouldn't it potentially loose less precision if you sorted on absolute values and summed from the smallest absolute value up? We could hope that people read the talk page before using code snippets? --[[User:Paddy3118|Paddy3118]] 16:07, 20 June 2009 (UTC)

:: I suppose in a "moving average" you can't sort operands, unless you store them, and doing so has not so good implications. I suppose also that investigating the limits of IEEE floating point is not the focus of the task. Users run code on RC at their own risk! --[[User:ShinTakezou|ShinTakezou]] 15:27, 21 June 2009 (UTC)

Revision as of 15:27, 21 June 2009

Numerical soundness

The implementations which use or permit floats and keep a running sum which is added to and subtracted from, if given nontrivial numbers, will eventually have the sum drift away from the actual value because floating-point arithmetic is nonassociative ((((a + b) + c) + d) - a is not necessarily equal to (((a - a) + b) + c) + d = (b + c) + d); should this be considered incorrect, or warned about? --Kevin Reid 14:51, 20 June 2009 (UTC)

Hmm, and wouldn't it potentially loose less precision if you sorted on absolute values and summed from the smallest absolute value up? We could hope that people read the talk page before using code snippets? --Paddy3118 16:07, 20 June 2009 (UTC)
I suppose in a "moving average" you can't sort operands, unless you store them, and doing so has not so good implications. I suppose also that investigating the limits of IEEE floating point is not the focus of the task. Users run code on RC at their own risk! --ShinTakezou 15:27, 21 June 2009 (UTC)