I've been trying to find information on the sampling distribution of the standard deviation for uniform distributions and have been having a heck of a time figuring out the expected value for the standard deviation of a sample. Hopefully someone can help out!
Basically, I'm trying to find the expected standard deviation given sample size n. Given a uniform, continuous distribution with population range (b-a), I know that the population standard deviation would be (b-a)/sqrt(12); however, what would be the expected standard deviation for a sample size n drawn from that continuous uniform distribution?
My hope is that given a Uniform Distribution with range W (or "PopRange" in the example below), I would like to calculate an expected standard deviation for a given sample size. Since the mean sample standard deviation changes as a function of the sample size, I'm hoping to quantify it. Here's some MATLAB code illustrating what I am hoping to achieve.
% Number of samples for the brute-force estimation
totalSamples = 10000;
% The population range (b-a)
PopRange = 30;
for n = 2:100
% Draw samples of sample size n
theSamples = rand(n,totalSamples)*PopRange;
% Calculate the mean of the standard deviations and ranges. This
% should be equivalent to the means of the sampling distributions
% of the standard deviation and range
uniformSampleSD(n) = mean(std(theSamples,[],1));
uniformSampleRange(n) = mean(max(theSamples,[],1)-min(theSamples,[],1));
% Calculate the expected standard deviation, note that this is just the
% population standard deviation at the moment and does not incorporate
% the sample size
uniformSampleESD(n) = PopRange/sqrt(12);
% SEE: https://en.wikipedia.org/wiki/Prediction_interval#Non-parametric_methods
% Calculate the expected sample range
uniformSampleERange(n) = (n-1)/(n+1)*PopRange;
end
% Note the red curve underestimating the population standard deviation for
% smaller sample sizes? This is fine, but I would like to find a numerical
% estimate for it
figure
plot(uniformSampleSD,'r')
hold on
plot(uniformSampleESD,'b')
Any help or pointers would be greatly appreciated!
Edit:
Perhaps I mis-worded what I am looking for? I am looking for the mean of the sampling distribution of the standard deviation for a continuous distribution.
If I draw 100000 sets from a uniform distribution [0,1] of sample size n, the distribution of standard deviations will not have a mean of sqrt((1-0)^2 / 12) = 0.289. Empirically, the mean of the sampling distribution of the sd will be:
n = 2, sd_mean = 0.235
n = 3, sd_mean = 0.263
n = 4, sd_mean = 0.273
n = 5, sd_mean = 0.278
n = 6, sd_mean = 0.280
n = 7, sd_mean = 0.282
n = 8, sd_mean = 0.283
n = 9, sd_mean = 0.284
n = 10, sd_mean = 0.285
Note that it asymptotically approaches sqrt((b - a)^2 / 12), but that this is inaccurate for small n. See these examples of the sampling distributions for those small n:
http://imgur.com/a/Asgkz (note: the "population" and "observed" sd line labels were accidentally swapped)
These were created using this code: totalSamples = 100000;
for n = 2:10
theSamples = rand(n,totalSamples);
setSDs = std(theSamples,[],1);
popSD = sqrt((1-0)^2/12);
nelements = hist(setSDs,50);
figure
hist(setSDs,50)
hold on
plot([popSD popSD],[0,max(nelements)],'r')
plot([mean(setSDs) mean(setSDs)],[0,max(nelements)],'g')
xlabel('Count')
ylabel('Sample Standard Deviation')
title({'Sampling Distribution of the Standard Deviation with 100000 sets';sprintf('drawn from a uniform distribution [0,1] with sample size %u',n)})
legend('Observations',sprintf('Pop SD = %f',popSD),sprintf('Observed Mean Sample SD = %f',mean(setSDs)))
end