SPSS 17 showing wrong result at top of window

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

SPSS 17 showing wrong result at top of window

jenmabrey

I’m pulling this number from a specific encounter I’ve had.  If I have a variable with the value .5125 and multiply that by 100, using either the compute function or compute syntax, it will show 51.25000 in the cell for that case/variable, but the bar at the top (I don’t know what it’s called, it’s where the “formula bar” is in Excel) will show 51.24999999999999.  I only have this issue with SPSS 17, it does not happen with 15, 15 will show 51.25.  Has anyone encountered anything similar?  Is there a patch for this?

This email message is intended for use only by the person(s) or entity to which it is addressed and may contain privileged or confidential information owned by rsc THE QUALITY MEASUREMENT COMPANY. Any unauthorized use or disclosure of this information is strictly prohibited. Copyright 2009 rsc. All rights reserved

This email message is intended for use only by the person(s) or entity to which it is addressed and may contain privileged or confidential information owned by rsc THE QUALITY MEASUREMENT COMPANY. Any unauthorized use or disclosure of this information is strictly prohibited. Copyright 2009 rsc. All rights reserved

Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17 showing wrong result at top of window

David Hitchin
Quoting "Mabrey, Jennifer L." <[hidden email]>:

> If I have a variable with the value .5125 and multiply that by 100,
> using either the compute function or compute syntax, it will show
> 51.25000 in the cell for that case/variable, but the bar at the top
> will show 51.24999999999999.

Like nearly all modern computers, the ones on which SPSS runs store
numbers in binary, not in decimal. Some decimal fractions can't be
stored exactly in binary (just as 1/3 can't be written exactly as a
decimal fraction). The result is that both rounding and truncation
errors can occur, and the final result of a computation might or might
not be what would have been achieved if working to infinite precision or
with a different number base.

The "error" here is 1 part in 100,000 million, and I can't think of any
practical problem in which a difference of this size would be of any
importance whatsoever.

It might be of interest with respect to theoretical issues, such as
those in number theory. People working in this field would not use SPSS,
but other packages which store numbers in other, sometimes very
complicated ways, in order to achieve very high precision.

David Hitchin

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17 showing wrong result at top of window

Richard Ristow
In reply to this post by jenmabrey
At 02:52 PM 2/27/2009, Mabrey, Jennifer L. wrote:

>If I have a variable with the value .5125 and multiply that by 100,
>using either the compute function or compute syntax, it will show
>51.25000 in the cell for that case/variable, but the bar at the top
>(I don't know what it's called, it's where the "formula bar" is in
>Excel) will show 51.24999999999999.

>Has anyone encountered anything similar?

Yes; the same question arose last November (thread "SPSS 17: wrong
result computing 3 * 0.7", begun Thu, 13 Nov 2008 08:55:40 -0500).
It's not just you.

>   Is there a patch for this?

There's supposed to be. At 05:49 PM 11/13/2008, Fry, Jonathan B.,
<[hidden email]> wrote:
>This is actually fixed in an upcoming patch,

I don't know if the patch has been released.

As in the earlier case, the value you get is accurate within about
one part in 2**52; that is, at least close to the theoretical machine
precision of one part in 2**54 (i.e., 1/2 least-significant bit).
Apparently, the problem is with rounding for display, not with computation.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17 showing wrong result at top of window

David Hitchin
In reply to this post by jenmabrey
Quoting "Mabrey, Jennifer L." <[hidden email]>:

> If I have a variable with the value .5125 and multiply that by 100,
> it will show 51.25000 in the cell for that case/variable, but
> the bar at the top will show  51.24999999999999.

I'm sorry that I overstated the error in my previous message as 1 in
100,000 million. It should actually have been much smaller,  e.g. 1 in
5,125,000,000,000,000.

Just to get a feeling for the size of that error, if you measure the
distance of the sun from the earth with an error of that size, you will
be wrong by about 1/30 of a millimetre, or just over 1/1,000 of an inch.

In most cases figures as shown to 14 decimal places will be more
accurate than when they are rounded to 5 decimal places, and it is only
the combination of two errors, first truncation and then rounding, which
by chance show the "correct" figure above.

David Hitchin

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17 showing wrong result at top of window

Keefer, Robert P.
In reply to this post by jenmabrey
Actually, a mathematician friend (thanks Terri!) once demonstrated to me that 2 is actually equal to 1.999999... , if the nines go on infinitely.  I cannot reproduce the proof, but someone in your math department probably can. 
 
bob k.

Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17 showing wrong result at top of window

Peck, Jon
In reply to this post by David Hitchin
Just to be sure that the point is clear, the smidgen of difference that is addressed in the patch that was mentioned is in the display, not the internal value.  Internal values, as has often been discussed on this list and elsewhere, use the closest binary approximation available in double precision floating point hardware to the specified decimal value.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Hitchin
Sent: Sunday, March 01, 2009 12:42 AM
To: [hidden email]
Subject: Re: [SPSSX-L] SPSS 17 showing wrong result at top of window

Quoting "Mabrey, Jennifer L." <[hidden email]>:

> If I have a variable with the value .5125 and multiply that by 100,
> it will show 51.25000 in the cell for that case/variable, but
> the bar at the top will show  51.24999999999999.

I'm sorry that I overstated the error in my previous message as 1 in
100,000 million. It should actually have been much smaller,  e.g. 1 in
5,125,000,000,000,000.

Just to get a feeling for the size of that error, if you measure the
distance of the sun from the earth with an error of that size, you will
be wrong by about 1/30 of a millimetre, or just over 1/1,000 of an inch.

In most cases figures as shown to 14 decimal places will be more
accurate than when they are rounded to 5 decimal places, and it is only
the combination of two errors, first truncation and then rounding, which
by chance show the "correct" figure above.

David Hitchin

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17 showing wrong result at top of window

Fry, Jonathan B.
In reply to this post by jenmabrey

The result at the top of the data editor window is not wrong, just surprising.  Try this little experiment on your copy.

 

data list free/ a b.

begin data

.5125 51.25

end data

compute a = a*100.

compute c = a eq b.

LIST .

 

Look in the data editor at the values of variables A and B.  The data editor is perfectly capable of showing 51.25 precisely, but that's not the value of .5125*100.

 

The trouble is that .5125 does not have an exact binary representation.  The closest 53-bit binary fraction to it is slightly smaller.  That makes the result of 100*.5125 slightly smaller than 51.25 (which does have an exact binary representation).

 

Jonathan Fry

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mabrey, Jennifer L.
Sent: Friday, February 27, 2009 1:52 PM
To: [hidden email]
Subject: SPSS 17 showing wrong result at top of window

 

I’m pulling this number from a specific encounter I’ve had.  If I have a variable with the value .5125 and multiply that by 100, using either the compute function or compute syntax, it will show 51.25000 in the cell for that case/variable, but the bar at the top (I don’t know what it’s called, it’s where the “formula bar” is in Excel) will show 51.24999999999999.  I only have this issue with SPSS 17, it does not happen with 15, 15 will show 51.25.  Has anyone encountered anything similar?  Is there a patch for this?

This email message is intended for use only by the person(s) or entity to which it is addressed and may contain privileged or confidential information owned by rsc THE QUALITY MEASUREMENT COMPANY. Any unauthorized use or disclosure of this information is strictly prohibited. Copyright 2009 rsc. All rights reserved

This email message is intended for use only by the person(s) or entity to which it is addressed and may contain privileged or confidential information owned by rsc THE QUALITY MEASUREMENT COMPANY. Any unauthorized use or disclosure of this information is strictly prohibited. Copyright 2009 rsc. All rights reserved

Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17 showing wrong result at top of window

Arthur Burke
In reply to this post by Keefer, Robert P.

  X =  1.999...
10X = 19.999...

(10X - X) = (19.999... - 1.999..)
9X = 18
 X = 2

 
Art
________________________________________
Art Burke
Northwest Regional Educational Laboratory
101 SW Main St, Suite 500
Portland, OR 97204-3213


________________________________

From: Keefer, Robert P. [[hidden email]]
Sent: Sunday, March 01, 2009 6:48 AM
To: [hidden email]
Subject: Re: SPSS 17 showing wrong result at top of window


Actually, a mathematician friend (thanks Terri!) once demonstrated to me that 2 is actually equal to 1.999999... , if the nines go on infinitely.  I cannot reproduce the proof, but someone in your math department probably can.    bob k.
________________________________

Reply | Threaded
Open this post in threaded view
|

Re: SPSS 17 showing wrong result at top of window

Roberts, Michael

Hi Art,

 

I may be wrong, but it looks like this proof is skirting the issue by using implicit rounding(?)

For example - if I set X = 1.9999 (using four decimals, or any finite number of decimals), then

10X = 19.9990,

then 10X – X = 9X

so, 9X = (19.999 – 1.9999) = 17.9991

then 9X = 17.9991,

and X = 1.9999 not 2

?

 

mike

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Arthur Burke
Sent: Tuesday, March 03, 2009 11:47 AM
To: [hidden email]
Subject: Re: SPSS 17 showing wrong result at top of window

 

  X =  1.999...
10X = 19.999...

(10X - X) = (19.999... - 1.999..)
9X = 18
 X = 2

 

Art
________________________________________
Art Burke
Northwest Regional Educational Laboratory
101 SW Main St, Suite 500
Portland, OR 97204-3213


________________________________

From: Keefer, Robert P. [[hidden email]]
Sent: Sunday, March 01, 2009 6:48 AM
To: [hidden email]
Subject: Re: SPSS 17 showing wrong result at top of window


Actually, a mathematician friend (thanks Terri!) once demonstrated to me that 2 is actually equal to 1.999999... , if the nines go on infinitely.  I cannot reproduce the proof, but someone in your math department probably can.    bob k.
________________________________