mvncdf - invert sum direction

조회 수: 2 (최근 30일)
James Mulhern
James Mulhern 2020년 10월 1일
댓글: James Mulhern 2020년 10월 6일
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.

채택된 답변

Jeff Miller
Jeff Miller 2020년 10월 1일
(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
James Mulhern
James Mulhern 2020년 10월 6일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by