comp.lang.ada
 help / color / mirror / Atom feed
* OT: definition of "significant figures"
@ 2005-07-29  4:23 tmoran
  2005-07-29 14:46 ` Jacob Sparre Andersen
  2005-07-31  8:36 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 11+ messages in thread
From: tmoran @ 2005-07-29  4:23 UTC (permalink / raw)


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?



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
  2005-07-29  4:23 OT: definition of "significant figures" tmoran
@ 2005-07-29 14:46 ` Jacob Sparre Andersen
  2005-07-30 23:44   ` Dr. Adrian Wrigley
  2005-07-31  8:36 ` Dmitry A. Kazakov
  1 sibling, 1 reply; 11+ messages in thread
From: Jacob Sparre Andersen @ 2005-07-29 14:46 UTC (permalink / raw)


tmoran@acm.org writes:

> 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?

The base 10 logarithm of the standard-deviation of your measurements.

Jacob (who as a physicist admits that he may make sign and
       factor-of-two errors)
-- 
�You have to blow things up to get anything useful.�
                                  -- Archchancellor Ridcully




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
  2005-07-29 14:46 ` Jacob Sparre Andersen
@ 2005-07-30 23:44   ` Dr. Adrian Wrigley
  2005-07-31  7:02     ` tmoran
  2005-08-01  7:31     ` Jacob Sparre Andersen
  0 siblings, 2 replies; 11+ messages in thread
From: Dr. Adrian Wrigley @ 2005-07-30 23:44 UTC (permalink / raw)


On Fri, 29 Jul 2005 16:46:36 +0200, Jacob Sparre Andersen wrote:

> tmoran@acm.org writes:
> 
>> 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?
> 
> The base 10 logarithm of the standard-deviation of your measurements.

this looks like one of those physicist's sign errors!

How about:

*Minus* the base 10 logarithms of the standard deviation =>
  *decimal places*

For example:
SD=0.1   => use 1 decimal place
SD=0.001 => use 3 decimal places

Note that decimal places are not significant figures!

Significant figures = Log10 (mean / standard deviation) + C

I think people also add in the (small) constant, for
good measure, depending on how they feel about the data distribution.

YMMV
-- 
Adrian




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
  2005-07-30 23:44   ` Dr. Adrian Wrigley
@ 2005-07-31  7:02     ` tmoran
  2005-08-01  7:31     ` Jacob Sparre Andersen
  1 sibling, 0 replies; 11+ messages in thread
From: tmoran @ 2005-07-31  7:02 UTC (permalink / raw)


> Significant figures = Log10 (mean / standard deviation) + C
>
> I think people also add in the (small) constant, for
> good measure, depending on how they feel about the data distribution.
   I've posted at
home.comcast.net/~tommoran4/sigfig.zip
a package to print the average of a set of measurements to the "right"
number of significant figures, and to get the error implied by the
figures in a value read in.  I used
  Sigfig_Count := Integer(- Long_Float'Floor(Log(Sd / abs (Avg), 10.0)));
rather than rounding the log.  I'm not sure I always agree with the
result, but it seems within a quibble of right.  The routine also seems
excessively long for what it does, but a better approach isn't obvious.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
  2005-07-29  4:23 OT: definition of "significant figures" tmoran
  2005-07-29 14:46 ` Jacob Sparre Andersen
@ 2005-07-31  8:36 ` Dmitry A. Kazakov
  2005-07-31 19:08   ` tmoran
  1 sibling, 1 reply; 11+ messages in thread
From: Dmitry A. Kazakov @ 2005-07-31  8:36 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
  2005-07-31  8:36 ` Dmitry A. Kazakov
@ 2005-07-31 19:08   ` tmoran
  0 siblings, 0 replies; 11+ messages in thread
From: tmoran @ 2005-07-31 19:08 UTC (permalink / raw)


> If you have, say, 100_000 approximately same FP numbers,
> then a naive implementation
> ...
> 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.
  For large N I keep log2(N) partial sums at the various scales.  Is that
what you mean by "cascade"?

> 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.
   I presume that for scientific publication one shows standard deviation
or confidence intervals or some appropriate statistic.  "significant
figures" seems more a rough-and-ready approximate way to convey that
information.  My immediate application actually takes a single decimal
latitude or longitude, whose accuracy I can only estimate from its number
of digits, and produces degrees/minutes/seconds, with an appropriate
number of significant fields/digits.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
       [not found] <e3nqe19bqp99h20anetgc7m63ai8ol84nv@4ax.com>
@ 2005-08-01  4:11 ` tmoran
  2005-08-01  6:50 ` tmoran
  1 sibling, 0 replies; 11+ messages in thread
From: tmoran @ 2005-08-01  4:11 UTC (permalink / raw)



>         The average of 2.1, 33.1, 2.2 -> is 12.5... Not 12.47, 12.46, or
> 12.46666
  The std dev is 16.24 which is > 12.4666, log(avg/sd) = -.115 so by
the log(avg/sd) definition there are fewer than 1 significant digits.
So the average of 2.1, 33.1, 2.2 would be "10", or perhaps even "10**1"



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
       [not found] <e3nqe19bqp99h20anetgc7m63ai8ol84nv@4ax.com>
  2005-08-01  4:11 ` tmoran
@ 2005-08-01  6:50 ` tmoran
  2005-08-01 16:58   ` tmoran
  1 sibling, 1 reply; 11+ messages in thread
From: tmoran @ 2005-08-01  6:50 UTC (permalink / raw)


I think a better formula for the number of digits to display is
   Digit_Count := Integer(Long_Float'ceiling(Log(Abs(Avg),10.0)))
                  -Integer(Log(Sd,10.0));
where the positive addition to the digits comes from a 'ceiling on
log(avg), but a subtraction from the number of digits comes from a
rounded value of log(sd)
  Using this formula, one gets
>         The average of 2.1, 33.1, 2.2
avg = 12.46666, sd =  16.24
    log(avg) = 1.096, 'ceiling = 2
    log(sd)  =-1.211, rounded  = 1
so the digit count is 1, rather than log(avg/sd)= -0.1
  If you don't use the 'ceiling, consider the case where the x(i) are
in the range 99.990 .. 99.999, vs the same set with .01 added, so
their range is 100.000 .. 100.009   Since their std devs are the same,
in the .00x range, their averages ought to be represented with the same
number of digits to the right of the decimal.  The 100's shouldn't
lose a digit compared to the 9's.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
  2005-07-30 23:44   ` Dr. Adrian Wrigley
  2005-07-31  7:02     ` tmoran
@ 2005-08-01  7:31     ` Jacob Sparre Andersen
  1 sibling, 0 replies; 11+ messages in thread
From: Jacob Sparre Andersen @ 2005-08-01  7:31 UTC (permalink / raw)


Adrian Wrigley wrote:
> On Fri, 29 Jul 2005 16:46:36 +0200, Jacob Sparre Andersen wrote:
> > tmoran@acm.org writes:

> >> 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?
> > 
> > The base 10 logarithm of the standard-deviation of your measurements.
> 
> this looks like one of those physicist's sign errors!

I know. ;)

> How about:
> 
> *Minus* the base 10 logarithms of the standard deviation =>
>   *decimal places*

Yes.  Apparently I didn't even understand the question.

> For example:
> SD=0.1   => use 1 decimal place
> SD=0.001 => use 3 decimal places
> 
> Note that decimal places are not significant figures!

Yes.

> Significant figures = Log10 (mean / standard deviation) + C
> 
> I think people also add in the (small) constant, for good measure,
> depending on how they feel about the data distribution.

Yes.

Jacob (who should start thinking before he posts)
-- 
Growing older is compulsory. Growing up isn't.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
  2005-08-01  6:50 ` tmoran
@ 2005-08-01 16:58   ` tmoran
  2005-08-01 23:56     ` tmoran
  0 siblings, 1 reply; 11+ messages in thread
From: tmoran @ 2005-08-01 16:58 UTC (permalink / raw)


oops,
>  Digit_Count := Integer(Long_Float'ceiling(Log(Abs(Avg),10.0)))
>                 -Integer(Log(Sd,10.0));
should be
   Digit_Count := Integer(1.0+Long_Float'floor(Log(Abs(Avg),10.0)))
                  -Integer(Log(Sd,10.0));



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: OT: definition of "significant figures"
  2005-08-01 16:58   ` tmoran
@ 2005-08-01 23:56     ` tmoran
  0 siblings, 0 replies; 11+ messages in thread
From: tmoran @ 2005-08-01 23:56 UTC (permalink / raw)


Pursuant to discussions here, I've posted a revised sigfig package at
home.comcast.net/~tommoran4/sigfig.zip



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-08-01 23:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-29  4:23 OT: definition of "significant figures" tmoran
2005-07-29 14:46 ` Jacob Sparre Andersen
2005-07-30 23:44   ` Dr. Adrian Wrigley
2005-07-31  7:02     ` tmoran
2005-08-01  7:31     ` Jacob Sparre Andersen
2005-07-31  8:36 ` Dmitry A. Kazakov
2005-07-31 19:08   ` tmoran
     [not found] <e3nqe19bqp99h20anetgc7m63ai8ol84nv@4ax.com>
2005-08-01  4:11 ` tmoran
2005-08-01  6:50 ` tmoran
2005-08-01 16:58   ` tmoran
2005-08-01 23:56     ` tmoran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox