Calculating confidence intervals for a non-normal distribution

Josiah picture Josiah · Dec 20, 2010 · Viewed 38.6k times · Source

First, I should specify that my knowledge of statistics is fairly limited, so please forgive me if my question seems trivial or perhaps doesn't even make sense.

I have data that doesn't appear to be normally distributed. Typically, when I plot confidence intervals, I would use the mean +- 2 standard deviations, but I don't think that is acceptible for a non-uniform distribution. My sample size is currently set to 1000 samples, which would seem like enough to determine if it was a normal distribution or not.

I use Matlab for all my processing, so are there any functions in Matlab that would make it easy to calculate the confidence intervals (say 95%)?

I know there are the 'quantile' and 'prctile' functions, but I'm not sure if that's what I need to use. The function 'mle' also returns confidence intervals for normally distributed data, although you can also supply your own pdf.

Could I use ksdensity to create a pdf for my data, then feed that pdf into the mle function to give me confidence intervals?

Also, how would I go about determining if my data is normally distributed. I mean I can currently tell just by looking at the histogram or pdf from ksdensity, but is there a way to quantitatively measure it?

Thanks!

Answer

MarkV picture MarkV · Dec 20, 2010

So there are a couple of questions there. Here are some suggestions

You are right that a mean of 1000 samples should be normally distributed (unless your data is "heavy tailed", which I'm assuming is not the case). to get a 1-alpha-confidence interval for the mean (in your case alpha = 0.05) you can use the 'norminv' function. For example say we wanted a 95% CI for the mean a sample of data X, then we can type

N = 1000;             % sample size
X = exprnd(3,N,1);    % sample from a non-normal distribution
mu = mean(X);         % sample mean (normally distributed)
sig = std(X)/sqrt(N); % sample standard deviation of the mean
alphao2 = .05/2;      % alpha over 2   
CI = [mu + norminv(alphao2)*sig ,...
      mu - norminv(alphao2)*sig  ]

CI =

2.9369    3.3126

Testing if a data sample is normally distribution can be done in a lot of ways. One simple method is with a QQ plot. To do this, use 'qqplot(X)' where X is your data sample. If the result is approximately a straight line, the sample is normal. If the result is not a straight line, the sample is not normal.

For example if X = exprnd(3,1000,1) as above, the sample is non-normal and the qqplot is very non-linear:

X = exprnd(3,1000,1);
qqplot(X);

alt text

On the other hand if the data is normal the qqplot will give a straight line:

qqplot(randn(1000,1))

alt text