Thread Subject: Numerical Problem: Successive Mean() calls on 6-D Matrix Returns

Subject: Numerical Problem: Successive Mean() calls on 6-D Matrix Returns

From: mprocopio@gmail.com

Date: 5 May, 2009 20:27:18

Message: 1 of 4

Hi folks,

I have encountered a very strange numerical issue in MATLAB R2009a
running on Windows XP x64.

I have a 6-d data matrix:

>> size(data)

ans =

      114529 3 2 3 4
2


This matrix is quite large:

>> whos data
  Name Size Bytes Class Attributes

  data 6-D 131937408 double



Successively calling mean() on the same data returns different
results:

>> mean(data(:,1,1,1,1,1)) == mean(data(:,1,1,1,1,1))

ans =

     0

>> mean(data(:,1,1,1,1,1)) == mean(data(:,1,1,1,1,1))

ans =

     1



This is illustrated more by subtracting the results of these calls.
Here is a sequence of successive calls:

>> mean(data(:,1,1,1,1,1)) - mean(data(:,1,1,1,1,1))

ans =

 -8.4703e-022

>> mean(data(:,1,1,1,1,1)) - mean(data(:,1,1,1,1,1))

ans =

  1.2705e-021

>> mean(data(:,1,1,1,1,1)) - mean(data(:,1,1,1,1,1))

ans =

 -1.6941e-021

>> mean(data(:,1,1,1,1,1)) - mean(data(:,1,1,1,1,1))

ans =

 -2.1176e-021

>> mean(data(:,1,1,1,1,1)) - mean(data(:,1,1,1,1,1))

ans =

  4.2352e-022

>> mean(data(:,1,1,1,1,1)) - mean(data(:,1,1,1,1,1))

ans =

     0

>> mean(data(:,1,1,1,1,1)) - mean(data(:,1,1,1,1,1))

ans =

  5.5057e-021

ver() Reports:

>> ver
-------------------------------------------------------------------------------------
MATLAB Version 7.8.0.347 (R2009a)
MATLAB License Number: 257546
Operating System: Microsoft Windows XP x64 Version 5.2 (Build 3790:
Service Pack 2)
Java VM Version: Java 1.6.0_04-b12 with Sun Microsystems Inc. Java
HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------
MATLAB Version
7.8 (R2009a)
Image Processing Toolbox Version
6.3 (R2009a)
Mapping Toolbox Version
2.7.2 (R2009a)
Parallel Computing Toolbox Version
4.1 (R2009a)
Signal Processing Toolbox Version
6.11 (R2009a)
Statistics Toolbox Version
7.1 (R2009a)



I'm at an absolute loss. Does anyone have an idea of what's going on
here?


Thank you,

--Mike

Subject: Numerical Problem: Successive Mean() calls on 6-D Matrix Returns

From: mprocopio@gmail.com

Date: 7 May, 2009 23:09:13

Message: 2 of 4

Any thoughts on this? This is not expected behavior, right? (Bug in
computation or a hardware overheating issue?)

Subject: Numerical Problem: Successive Mean() calls on 6-D Matrix Returns

From: John D'Errico

Date: 7 May, 2009 23:27:01

Message: 3 of 4

mprocopio@gmail.com wrote in message <19ad427a-80ea-46b9-8083-b67fc971e01b@z8g2000prd.googlegroups.com>...
> Any thoughts on this? This is not expected behavior, right? (Bug in
> computation or a hardware overheating issue?)

data = rand(114529,3,2,3,4);

>> mean(data(:,1,1,1,1,1)) == mean(data(:,1,1,1,1,1))
ans =
     1

>> mean(data(:,1,1,1,1,1)) == mean(data(:,1,1,1,1,1))
ans =
     1

>> mean(data(:,1,1,1,1,1)) == mean(data(:,1,1,1,1,1))
ans =
     1

>> mean(data(:,1,1,1,1,1)) == mean(data(:,1,1,1,1,1))
ans =
     1

>> mean(data(:,1,1,1,1,1)) == mean(data(:,1,1,1,1,1))
ans =
     1

>> mean(data(:,1,1,1,1,1)) == mean(data(:,1,1,1,1,1))
ans =
     1

It is nothing that I can repeat. Is it possible that
you have defined your own mean function?

John

Subject: Numerical Problem: Successive Mean() calls on 6-D Matrix Returns

From: Matt

Date: 8 May, 2009 02:24:02

Message: 4 of 4

mprocopio@gmail.com wrote in message <19ad427a-80ea-46b9-8083-b67fc971e01b@z8g2000prd.googlegroups.com>...
> Any thoughts on this? This is not expected behavior, right? (Bug in
> computation or a hardware overheating issue?)

Have you checked whether it's a data-dependent phenomenon? What happens if you set all the data(:) to 0 or 1 and repeat these tests.

It might also help to test with the same data on a 32-bit machine.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com