matlab - Probabilities of bivariate normally distributed random variable -
i'm trying calculate probability of bivariate normal distribution on specific area using matlab.
lets assume random variable follows standard normal distribution , want calculate mass of unit circle.
i used following code:
fun = @(x,y) exp(-0.5*(x.^2+y.^2))/(2*pi); ymin = @(x) -sqrt(1-(x.^2)); ymax = @(x) sqrt(1-(x.^2)); integral2(fun,-1,1,ymin,ymax)
i 0.3935. i'm wondering result correct.
can confirm result correct or point on mistake made?
i think correct. checks:
integrate on large square , see if result
1
:>> integral2(fun,-5,5,-5,5) ans = 0.999998853581851
the 90-percentile of univariate gaussian distribution is
>> norminv(.9) ans = 1.281551565544601
so, integral of function on
[−∞,∞] × [−∞,1.281]
should0.9
:>> integral2(fun,-10,10,-10,norminv(.9)) ans = 0.900000750806316
the definitive, monte carlo check:
>> n = 1e6; x = randn(1,n); y = randn(1,n); mean((x>-1)&(x<1)&(y>-sqrt(1-(x.^2)))&(y<sqrt(1-(x.^2)))) ans = 0.393678000000000
Comments
Post a Comment