mvncdf - invert sum direction

3 views (last 30 days)
James Mulhern
James Mulhern on 1 Oct 2020
Commented: James Mulhern on 6 Oct 2020
Hello,
I am new to working with mvncdf and I have some basic test scripts working, however I would like to modify the direction over which the cdf is calculated.
There is some example code below
mu = [0, 10];
std = [2, 1];
dir = [1,-1];
sigma = std.^2.*eye(length(std));
X1_points = linspace(mu(1) - dir(1)*3*std(1),mu(1) + dir(1)*3*std(1),25)';
X2_points = linspace(mu(2) - dir(2)*3*std(2),mu(2) + dir(2)*3*std(2),25)';
[X1,X2] = meshgrid(X1_points,X2_points);
X = [X1(:),X2(:)];
p = mvncdf(X,mu,sigma);
Z = reshape(p,25,25);
figure()
surf(X1,X2,Z);
xlabel('X');
ylabel('Y');
This code runs fine (I stole most of it from the help doc) however I would like to move the location of where the maximum cdf value is. Currently the max cfd is at [6,13] which makes sense. I would like the max cdf to move to [6,7] becasuse the second parameter is worse with the lower values.
As you can see in the code I attempted to achive this by fliping the direction of the points arrays and the gridded data however this had no impact on the output.
Is there any way to change the way that mvncdf calculates the cumulative probabilities so it will sum along the positive direction for one variable and the negative direction for other variables.

Accepted Answer

Jeff Miller
Jeff Miller on 1 Oct 2020
(1) There is no way to get mvncdf to be larger at (6,7) than at (6,13).
(2) It might be useful to you to reconceptualize X2 as running from -13 to -7, keeping in mind that you have reversed its sign. At least, mvncdf will be larger at (6,-7) than at (6,-13). See if it makes sense when you change to these two lines:
X1_points = dir(1)*linspace(mu(1) - 3*std(1),mu(1) + 3*std(1),25)';
X2_points = dir(2)*linspace(mu(2) - 3*std(2),mu(2) + 3*std(2),25)';
  1 Comment
James Mulhern
James Mulhern on 6 Oct 2020
This would likely work, however I did it a differnt way.
I set all of the means to zero and then after mvncdf completed I added or subtracted the value of the test point from the mean depending on the direction.
Since I am arbitrally generating the CDF points this method worked for me.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!