Any ideas how to reduce run time with mvncdf?

4 views (last 30 days)
Hi all,
My code is the following:
q=1;
while q<=3
[w x y1 z]=ndgrid(A,A,A,A);
m=[2.326 1.466 0.9539];
parfor i=1:length(w(:))
fp(i)=mvncdf([w(i) x(i) y1(i) z(i)],[inf inf inf inf],zeros(1,n),[1 0.3 0.3 0.3; 0.3 1 0.3 0.3; 0.3 0.3 1 0.3; 0.3 0.3 0.3 1]);
tp(i)=mvncdf([w(i) x(i) y1(i) z(i)],[inf inf inf inf],repmat(m(q),[1 n]),[1 0.3 0.3 0.3; 0.3 1 0.3 0.3; 0.3 0.3 1 0.3; 0.3 0.3 0.3 1]);
oc(i)=(N*C(1))+C(2)*((1-normcdf(w(i),m(q),1))*pt+(1-normcdf(w(i)))*(1-pt))+C(3)*((1-normcdf(x(i),m(q),1))*pt+(1-normcdf(x(i)))*(1-pt))+C(4)*((1-normcdf(y1(i),m(q),1))*pt+(1-normcdf(y1(i)))*(1-pt));
end
curve=sortrows([fp' tp' oc'],1);
rcrv=rocc(curve(:,1),curve(:,2));
bc=(1-rcrv(:,2))+rcrv(:,1);
tc=g*curve(:,3)+(1-g)*bc;
cbn{q}=[rcrv(:,1) rcrv(:,2) curve(:,3) bc tc];
q=q+1;
end
I have matlabpool open in the local config (so that's not the issue). The issue here is that for this many elements, the computation is taking too long. I only need approximately five significant figures. I have to run scripts like this multiple times and my computer resources are modest. Does anyone have any thoughts on increasing the computability of this code? Thank you.
-Alex

Answers (0)

Community Treasure Hunt

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

Start Hunting!