Re: Accuracy and Precision

• To: mathgroup at christensen.cybernetics.net
• 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 news0.cybernetics.net> Paul E Howland <PEHOWLAND at taz.dra.hmg.gb> 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
equation.

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]}

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

In[3]:=sap[10.]
Out[3]={1, 15, 16}

In[4]:=sap[N[E^10,30]]
Out[4]={4.3429448190325182765112891892, 24, 29}

In[5]:=sap[\$MinMachineNumber]
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
10^-6.

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
\$MachinePrecision.

Some examples:

In[6]:=NIntegrate[Exp[x],{x,0,1},AccuracyGoal->6,PrecisionGoal->Infinity]
Out[6]=1.71828

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

In[7]:=NIntegrate[10.^20 Exp[x],{x,0,1},AccuracyGoal->6,PrecisionGoal->Infinity]
NIntegrate::ploss:
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.
Out[7]=
20
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]
Out[8]=
20
1.71828 10

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

Rob Knapp
WRI

```

• 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