开发者

mean variance of uniform distribution over [0,1] MATLAB

What is the best w开发者_如何学编程ay in Matlab to get the mean and variance of a uniform distribution over [0,1]?.


Mean and variance of an empirical distribution are calculated the same way for any distribution:

%# create uniform distribution
N = 1000;
dist = rand(N); %# N values, uniformly distributed between 0 and 1

%# calculate mean and variance
distributionMean = mean(dist);
distributionVariance = var(dist);

This approach provides an estimate for the mean and variance of the distribution from which your sample was drawn. Note that with larger N, distributionMean will approach 0.5, and distributionVariance will approach 1/12. If that's the values you're really interested in, the useful Matlab command is

web('http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)')


The mean and variance of a Uniform (0,1) or even a Uniform(a,b) random variable are known formulas.

For X~Uniform(a,b),

mean(X) = (a+b)/2

var(X) = (1/12)*((b-a)^2)

Set a = 0 and b = 1 for the desired result.

Read more here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜