views:

542

answers:

3

Hi

I have some data points and their mean point. I need to find whether those data points (with that mean) follows a Gaussian distribution. Is there a function in MATLAB which can do that kind of a test? Or do I need to write a test of my own?

I tried looking at different statistical functions provided by MATLAB. I am very new to MATLAB so I might have overlooked the right function.

cheers

+3  A: 

For testing in general, look up the Kolmogorov-Smirnov Test, also in the Stats Toolbox, as kstest and the two-sample version: kstest2 . You feed it your empirical data, (and the data from a possible function, like the gaussian, etc...) then it tests the likelihood that your sample was pulled from the normal distribution (or the one you supplied for the two-sample version)... The nicety is that it'll work for any possible distributions...

Alex Cohen
+1  A: 

I like Spiegelhalter's test (D. J. Spiegelhalter, 'Diagnostic tests of distributional shape,' Biometrika, 1983):

function pval = spiegel_test(x)
% compute pvalue under null of x normally distributed;
% x should be a vector;
xm = mean(x);
xs = std(x);
xz = (x - xm) ./ xs;
xz2 = xz.^2;
N = sum(xz2 .* log(xz2));
n = numel(x);
ts = (N - 0.73 * n) / (0.8969 * sqrt(n)); %under the null, ts ~ N(0,1)
pval = 1 - abs(erf(ts / sqrt(2)));    %2-sided test.

whenever hacking statistical tests, alway test them under the null! here's a simple example:

pvals = nan(10000,1);
for j=1:numel(pvals);
pvals(j) = spiegel_test(randn(300,1));
end
nnz(pvals < 0.05) ./ numel(pvals)

I get the results:

ans =    
   0.0505

Similarly

nnz(pvals > 0.95) ./ numel(pvals)

I get

ans = 
   0.0475
shabbychef
+4  A: 

Check this documentation page on all available hypothesis tests.

From those, for your purpose you can use:

... among others

You can also use some visual tests like:

Amro
I just don't like that these are all from the Mathwork$ $tatistic$ toolbox; one could easily hack together the e.g. Jarque-Bera without it, but for the rest, you have to import some files from `octave`. The other problem with a firehose of statistical tests is there is no indication of the relative power of each of them (true, it depends on the alternative hypothesis).
shabbychef

related questions