Docsity

Errors in Data Processing: Precision, Truncation, Rounding, and Propagation - Prof. Vicki , Study notes of School management&administration

Partial preview of the text

Download Errors in Data Processing: Precision, Truncation, Rounding, and Propagation - Prof. Vicki and more Study notes School management&administration in PDF only on Docsity!

Errors

Data^

Errors: Human^

error Bad^ MeasurementsModeling

Errors: Wrong^

formula Incorrect assumptionIncorrect

assumption Implementation

Errors: 1999 Mars

Orbiter

lost^ as^

Lockheed

Martins

programmed

using

English units^ but

NASA^ used

metric

units.

Precision

-^ Floating

Point

numbers

(with

a^ decimal

and

exponent)

are^ stored

in^ three

pieces

-^ sign^

(0^ or^ 1)

-^ mantissa

or^ significand (value)

-^ exponent or magnitude–^ exponent or

magnitude

-^ Example

would

be^ written

as

5 X 10

(we^

say^ it

is^ normalized)

-^ sign^

0 as^ is^ positive

-^ mantissa

or^ significand (value)

is^.

-^ exponent

5

-^ The

precision

is^ the

number

of^ significant

digits

Recall

(^5) • 10 =^100000 (^4) • 10 =^10000 (^3) • 10 =^1000 (^2) • 10 =^

100 (^1) • 10 =^

10 (^0) • 10 =^

1 (anything

to^ the

zero^ power

is^ 1)

‐ • 10 1 =^

.^

(^1) 1/ (one

tenth)

‐ • 10 2 =^

.^

(^2) 1/ (one

hundredth)

‐ • 10 3 =^

.^

(^3) 1/ (one

thousandth)

‐ • 10 4 =^

.

(^4) 1/ (one

ten^ thousandth)

Example

-^874200 •^ In^ normali

zed^ form,

what

is^ the

precision,

magnitude

In normali ed form, what is the precision, magnitude and^ exponent? • 874200

=^.

(^6) x 10

-^ what is the precision

= 4 digits of accuracy

what

is^ the

precision

4 digits

of^ accuracy

-^ magnitude

=^6

-^ mantissa

mantissa

In^ a^ poorly

organized

long^

computation,

representation

errors

can^ accumulate,

culminating

in^ a^ floating

point

result

with a^ large

error.

For^ example,

a^ sum

of^ n

floating

point

numbers

can^ have

an^ error

as^ high

as

(^32) ‐ (^32) 2 (^) n2. Errors^ in^ small

differences

can^ also

cause

problems.

For

example,

an^ algorithm

that^

computes

1/(A

‐B)^ may

give

a^ divideby

zero error if A and B are within 2

‐^32 of each

a^ divideby

‐zero error

if^ A^ and

B^ are

within

32 2 of each

other.

Propagation

of^ Error

-^ When

you^ add

two^ numbers

that^

each^

have^

error,

what

is^ the

uncertainty

of^ the

sum?

-^ When

you^ multiply

two^ numbers

that^

each^

have

error,

what

is^ the

uncertainty

of^ the

product?

Absolute

and

relative

error

-^ Absolute

error:

the^ absolute

value

(throw

away

sign)

of^ the

difference

between

the^ exact

and^ the

computed

answer Example:

Area

of^ a^ polygon

is^ actually

272 square

pixels.

We^ estimated

150.^

What

is^ the

absolute

error?^ |

=^122

Which

of^ the

two

errors

is^ more

significant?

-^ If^ I^

am^ off

by^175

out^ of

or^ if^

I^ am^ off

by^122

out

of^ 272? • Relative

error

divides

the^ absolute

error

by^ the

actual y

answer. • 175/

=^.

or^ 3.8%

error

•^ 122/

=^.

or^ 44.8%

error

Truncate

to^3

significant

digits

-^874200 •^ In^ normali

zed^ form,

what

is^ the

precision,

In normali ed form, what is the precision, magnitude

and^ exponent?

-^874200

=^.

(^6) x 10

-^ what is the

desired

precision

= 3 digits of accuracy

what

is^ the

desired

precision

3 digits

of^ accuracy

-^ magnitude

=^6

-^ mantissa

= 874 (after truncation) mantissa

(after

truncation)

Round

off^ error

-^ Instead

of^ truncating

a^ number

to^ fit

in^ storage,

the

computer

might

round

-^874600 •^ In^ normalized

form,

what

is^ the

precision,

magnitude

,^

p^

,^ g

and^ exponent

rounded

to^ three

digits.

•^874600

=^.

(^6) x 10

-^ what

is^ the

precision

=^3 digits

of^ accuracy

p^

g^

y

-^ magnitude

=^6

-^ mantissa

= .875 (after rounding) mantissa

(after

rounding)

Round

‐off^ error

-^ The

error

between

what

you^ wanted

to^ store

and

what

you^ actually

could

store.

-^ Actually

  • just

“regular

error”

when

you^ are

rounding.

In^ Binary

-^ In^ binary,

these

same

kinds^

of^ problems

occur.

-^ Suppose

we^ have

a^ simple

integer

(with^

no^ fractional

part)

and that we have 4 bits for each integer.and^ that

we^ have

4 bits

for^ each

integer.

-^ Now

lets^ add

two^ numbers 1101

(13^ in^

decimal)

(13 i

d^ i

l)

(^

in^ decimal) 11010

(but, we^ have overflowed

our^ memory

as^ we

have^ a

four^ bit

limit) 0 0 i^

ll h^

ill b^

d ( 3^

3 0)

1010 i

s^ all^ that

will^ b e^ stored

(13+

=^ 10)

You^ ask

  • why

doesn’t

the^ machine

check

for^ the

error^

and^ warn

you.Well,^ it^ could,

but^ it

would

slow^ things

down.

Every

operation

would

be^ followed

by^ a^ check

to^ see

if^ overflowed.

We^ call

this^ “overkill”.

Suppose

we^ add

a^ small

number

to^ a

large

one

1.^ Suppose

we^ have

four^

digits

of^ accuracy.

is^ stored

as^157800

(^6) x 10

2.^ If^

we^ add

a^ small

number

to^ it,

we^ get

+^1 =

=^157800

(with

four^

digits

of^ accuracy)

3.^ We

may^

be^ “fine”

with that,

but^ if

we^ add

the^ small

b^

illi^

i^

i d^

’^

i h^

h

number

a^ million

times,

it^ doesn’t

seem

right

that

the^ original

number

never

changes.

We call this error propagation or cumulative error

It

We^ call

this^ error

propagation

or^ cumulative

error

.^ It

started

out^ small,

but^ after

repeated

additions,

it

had^ become

significant.

-^ From

Law…cumulative

error

is^ premised

on^ the

existence

of^ errors,

no^ one

of^ which

merits

reversal,

but^ in

combination

they necessitate

the^ reversal

of^ a

finding

or^ sentence;

-^ In^ navigation,

a^ 1%

error

in^ direction

becomes

significant

if^ you

are^ flying

miles.