mvncdf gives different results before and after the variable is standardised
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
stupid&confused
le 4 Mai 2023
Modifié(e) : stupid&confused
le 6 Mai 2023
Let X denote a normal variable with mean m and variance v, that is, X~.
We know ~. Such claim is consistent with the results of the following exercise. Suppose , and
m = 0; % setting a value for parameter m
v = 2; % setting a value for parameter v
X = 1.33; % generate some realised value for X
normcdf(X,m,sqrt(v)) % the third input is meant for the square root of variance
We get 0.8265. In the following, let's focus on the demeaned and standardised variable
normcdf(v^(-0.5)*(X-m),0,1)
We still get 0.8265.
Now let's move on to vector.
Let denote a bivariate normal vector with mean vector and covariance matrix , that is, ~.
We know ~, where is an identity matrix (for proof visit here). However, I have a tough time verifying this claim.
Suppose , and
m = [0;0]; % setting a value for parameter m
V = [2,0.2;0.2,4]; % setting a value for parameter V
X = [1.2;1.2]; % generate some realised value for X
mvncdf(X,m,V) % the third input is meant for the covariance matrix
We get 0.5887. In the following, let's focus on the demeaned and standardised variable
mvncdf(V^(-0.5)*(X-m),[0;0],eye(2))
We get 0.5709. This value is "close" but certainly not exactly 0.5887.
I wonder what is the reason behind this discrepency?
1 commentaire
Torsten
le 4 Mai 2023
The affine transformation y = V^(-0.5)*(X-m) does not transform axis-parallel rectangles to axis-parallel rectangles if the matrix V has off-diagonal elements. That's why the two integrals are not equal.
Réponse acceptée
John D'Errico
le 4 Mai 2023
Modifié(e) : John D'Errico
le 4 Mai 2023
No answer yet? The distinction as I see it is a subtle one. And had your covariance matrix been a diagonal one, then I expect it would have worked. But what happens when V is NOT a diagonal matrix?
Then, if we were to plot the multi-variate normal pdf, it would be this elliptical hill, but with the contours oriented along some direction that is not parallel to the axes. And that is a crucial difference.
MVNCDF computes the volume under a semi-infinite hyper-rectangle. So -inf along one edge of the rect. And that is what you want.
But what happens when you transform the problem by multiplying by the V^(-1/2)? That operation takes the edges of that semi-infinite hyper-rectangle, and makes them no longer at 90 degrees to each other. And that should explain your mistake. Now you need to compute the volume of a standard normal, but within a semi-infinite hyper-rhombus.
Again, if V was diagonal, then what was a 90 degree angle stays a 90 degree angle. It just stretches the axes. But the axes stay at 90 degrees.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Permanent Magnet Synchronous Motors (PMSM) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!