Hey there,
I drew samples for the beta distribution and noticed that the variance is off. It seems to be a structural issue. Any ideas?
a = 2; b = 2;
X = sample(@(x) (x.^(a-1).*(1-x).^(b-1) / beta(a,b)), [0 1], 100000);
mean(X), var(X) % = 0.5005, 0.0201
The analytical values for the mean and variance are
mu = a / (a + b) % 0.5
var = a*b/( (a+b)^2*(a+b+1) ) % 0.05
thanks!