MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Accuracy and Precision

  • To: mathgroup at
  • Subject: [mg769] Re: Accuracy and Precision
  • From: rknapp (Robert Knapp)
  • Date: Tue, 18 Apr 1995 01:03:14 -0400
  • Organization: The Santa Fe Institute

In article <3mf8nk$l4o at> Paul E Howland <PEHOWLAND at> writes:

> I'm struggling to get my head around the difference between Accuracy[]
> and Precision[], and similarly AccuracyGoal[] and PrecisionGoal[].  I'm 
> writing a small optimisation package at the moment, and would like my 
> options to be similar to those of FindMinimum[], but can't sort out the 
> difference.
> I get the same answer for Accuracy[1] as Precision[1], and 
> for Accuracy[1.] as Precision[1.], and for 
> 	Accuracy[1.000000000000000000000000000000000001] as
> 	Precision[1.000000000000000000000000000000000001].
> I'm afraid the accuracy of my brain is unable to cope.
However, I am sure the scale of your brain is quite able to cope.  

Introduction of the term scale makes the concept of accuracy and
precision easier to grasp because it can then be expressed as an

precision = scale + accuracy

where scale(number)  can be defined (roughly (due to roundoff of
accuracy and precision)) as Log[10,Abs[number]].
Note that is is possible for any of these quantities to be negative
(though in general zero is taken to be a lower bound for precision
because numbers with negative precision are generally not
particularily useful.)

Thus in your example since the scale is 0, the precision and accuracy
should be identical.  

Here are a few examples to further illustrate the idea.  

In[1]:=sap[number_] := {Log[10,Abs[number]],Accuracy[number],Precision[number]}

Out[2]={-1., 17, 16}

Out[3]={1, 15, 16}

Out[4]={4.3429448190325182765112891892, 24, 29}

Out[5]={-307.954, 324, 16}

Now as to AccuracyGoal and PrecisionGoal.  It is proabably easiest to
think of them separately.

AccuracyGoal is the number of digits of accuracy to seek (independent
of the precision).  Thus, whatever the scale of your answer,
AccuracyGoal is like an absolute error tolerance.  In fact, when the
AccuracyGoal is met, 

error <= 10^(-AccuracyGoal)

Thus, when using the default (6 on most machines with 16 digit
floating point numbers), you are shooting for an absolute tolerance of

PrecisionGoal is the number of precise digits in the result
independent of scale.  This is a relative error tolerance.  When the
precision goal is met, one can generally say

error <= scale(answer) 10^(-PrecisionGoal)

Thus, when using the default, you are shooting for your answer to have
6 meaningful digits.

When both are present, the error estimate looks something like this

error <= 10^(-AccuracyGoal) + scale(answer)*10^(-PrecisionGoal)

Thus an Accuracy or Precision goal of Infinity means you are using
exculsively the other one.

Note that AccuracyGoal and PrecisionGoal say nothing about the
precision and accuracy of the number returned--in general for
calculations done with the default WorkingPrecision =
$MachinePrecision, the precision of the numbers will be equal to

Some examples:


No sweat getting the answer to absolute tolerance 10^-6

In[7]:=NIntegrate[10.^20 Exp[x],{x,0,1},AccuracyGoal->6,PrecisionGoal->Infinity]
   Numerical integration stopping due to loss of precision.
     Achieved neither the requested PrecisionGoal nor
     AccuracyGoal; suspect one of the following: highly
     oscillatory integrand or the true value of the integral
     is 0.
1.71828 10

There is no chance it will get the answer to absolute tolerance of
10^-6 with only 16 digits to work with!!

In[8]:=NIntegrate[10.^20 Exp[x],{x,0,1},AccuracyGoal->Infinity,PrecisionGoal->6]
1.71828 10

However, it has no problem getting 6 digits of precision.

Rob Knapp

  • Prev by Date: Extracting data points from Plot[]
  • Next by Date: Re: Word - Mathematica connection
  • Previous by thread: Re: Accuracy and Precision
  • Next by thread: Re: Lyapunov Equation