How to test whether two arrays are statistically different?

This may be a silly question, but I don't have much of a background in statistics and I want to make sure I do this properly.
I have two 451x301 arrays. When plotted using imagesc(), they look extremely similar (although there are slight differences). Is there a way that I can test whether the two arrays are statistically different?

 Accepted Answer

I would plot them with surf and then look at each separately and then both together, depending on what they are (here, plotting the differences).
For example —
f = @(x,y) exp(-((x-1.1).^2/3 + (y-1.5).^2/4));
g = @(x,y) exp(-((x-1.2).^2/4 + (y-1.3).^2/3));
xv = linspace(-5, 5, 50);
[X,Y] = ndgrid(xv);
figure
surf(X,Y,f(X,Y))
title('f(x,y)')
figure
surf(X,Y,g(X,Y))
title('g(x,y)')
figure
surfc(X,Y,(f(X,Y)-g(X,Y)).^2)
title('(f(x,y) - g(x,y))^2')
A statistical test would depend on the matrices themselves and the how best to describe the differences.
The last plot calculates and plots the squared differences, and it is not obvious to me what statistical test would be most appropriate.
.

4 Comments

Thank you for the help. I have attached a .mat file with my variables. This is what I get when I use the surf() functions:
load data2d.mat
surf(lat,lon,f,'EdgeColor','none')
title('f(lat,lon)')
figure
surf(lat,lon,g,'EdgeColor','none')
title('g(lat,lon)')
figure
surf(lat,lon,(f-g).^2,'EdgeColor','none')
title('(f(lat,lon)-g(lat,lon))^2')
Is this helpful for determining which statistical test to use?
Since the distribution is not known, I would use the ranksum function (Wilcoxon rank-sum test). This requires that the matrices be reshaped as vectors —
[p,h,stats] = ranksum(f(:),g(:));
This results in:
p =
51.4541e-003
h =
logical
0
stats =
struct with fields:
zval: 1.9477e+000
ranksum: 10.0386e+009
The null hypothesis (‘h’) that they are different is rejected at the 5% significance level, so by this test, they are not different, supported by the p-value of 0.0515.
There may be other valid ways to test this, however ranksum appears to me to be appropriate here.
.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!