la variance moyenne de la distribution uniforme sur [0,1] Matlab
Question
Quelle est la meilleure façon Matlab pour obtenir la moyenne et la variance d'une distribution uniforme sur [0,1]
?.
La solution
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)')
Autres conseils
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.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow