x = randn(1000000,1);[fx,xi]=ksdensity(x);plot(xi,fx);a1 = qfunc(1.5);a2= qfunc(2);P = a2/a1;a1a2P
When I run this code, the values I get for a1 & a2 are exactly the value I get from analysis (a1 = 0.0668 & a2 = 0.0228) . But the division a2/a1 gives 0.3405 in matlab, where as the actual value of division should be 0.3413. Why does this happen?
The above code is solution to question below.
{Use the MATLAB randn function to generate a large number of samples according to a Gaussian distribution. Let A be the event A = {the sample is greater than 1.5}. Of those samples that are members of the event A, what proportion (relative frequency) is greater than 2? By computing this proportion you will have estimated the conditional probability
Pr( X > 2|X > 1. 5).
Calculate the exact conditional probability analytically and compare it with the numerical results obtained through MATLAB. }
Best Answer