Effacer les filtres
Effacer les filtres

qfunc() division

3 vues (au cours des 30 derniers jours)
Heshani
Heshani le 30 Août 2011
x = randn(1000000,1);
[fx,xi]=ksdensity(x);
plot(xi,fx);
a1 = qfunc(1.5);
a2= qfunc(2);
P = a2/a1;
a1
a2
P
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. }

Réponse acceptée

Lucas García
Lucas García le 30 Août 2011
Notice that you are dividing the outputs from qfunc using only 4 decimal points to verify your analytic result. Actually, MATLAB is showing a short visualization format when you type a1, a2 and P.
If you type format long and show the values for a1 and a2 you will notice that you are getting different results because you are truncating a1 and a2 to 4 decimal points when verifying your results:
0.0228/0.0668 = 0.3413
but actually, the correct result is:
>> P = a2/a1
P =
0.340534126802047
since a1 and a2 have many more decimal places...
  1 commentaire
Heshani
Heshani le 10 Sep 2011
Thanks, you made it very clear. :)

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by