From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,df84b868ad64e4f7 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!news.germany.com!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: OT: definition of "significant figures" Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Sun, 31 Jul 2005 10:36:22 +0200 Message-ID: <16rocpq66tyxr.x4l3edv2c9ce$.dlg@40tude.net> NNTP-Posting-Date: 31 Jul 2005 10:36:22 MEST NNTP-Posting-Host: f5b7e909.newsread2.arcor-online.net X-Trace: DXC=i=6lDOgF7;VD__2dTlB=E[Q5U85hF6f;TjW\KbG]kaMXLL]:kiR8f=_?:I@P>5V[5Z[6LHn;2LCV^I^><>f3dFYZ;6nN^PUS46[ X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:3864 Date: 2005-07-31T10:36:22+02:00 List-Id: On Thu, 28 Jul 2005 23:23:08 -0500, tmoran@acm.org wrote: > Given a set of measurements x(i), I'd like to print their average to > the "correct" number of significant figures. eg > 1.11, 1.12, 1.08 => "1.1", 1.11, 1.25, 1.35 => "1" > I've got some adhocery that more or less does it, but is there a > moderately standard, formal, definition? 1.11, 1.25, 1.35 => "1.0", I'd say. Zero is a figure as any other. BTW, the result depends on the way you are evaluating the average, whether fixed or floating-point is used. If you have, say, 100_000 approximately same FP numbers, then a naive implementation Average := 0.0; for I in X'Range loop Average := Average + X (I); end loop; Average := Average / Float (X'Length); would perform awfully. Near to the end of the loop you will heavily loose accuracy. Because the ratio Sum to X (I) would be around 100_000. To cascade it would be a better idea. So basically it is difficult to tell in advance how many "right" figures you get. Also you can use interval arithmetic, then you'll exactly know the accuracy of the result. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de