## Obscure error in mvncdf()

This error is kind of reproducible but kind of not reproducible. The following is a copy paste that of the output from matlab. Essentially, for a given value of the first two inputs to mvncdf() it throws an error

mvncdf(z_gridvals(1976,:)-z_gridspacing_down(1976,:),z_gridvals(1976,:)+z_gridspacing_up(1976,:),Mew,Sigma)

Error using gpuArray/log

LOG: needs to return a complex result, but this is not supported for real input X on the GPU. Use LOG(COMPLEX(X))

instead.

Error in internal.stats.bvncdf (line 70)

log(t1.*exp(-bsq./(2*asq)) – t2.*sqrt(2*pi).*Phi(-b./a)));

Error in mvncdf (line 249)

y = y + (-1)^i * internal.stats.bvncdf(X, rho, tol/4);

That is the error, but something as minor as the next lines of code being

aaa1=z_gridvals(1976,:)-z_gridspacing_down(1976,:);

aaa2=z_gridvals(1976,:)-z_gridspacing_up(1976,:);

mvncdf(aaa1,aaa2,Mew,Sigma)

ans =

0

and suddenly the error is gone.

This is really weird, because in principle the inputs are the same in both cases.

The values of the four inputs to mvncdf() are as follows (but just putting them in this way does not cause error)

aaa1=[4.546541072119, -19.52465262]

aaa2=[4.548657475153, -17.361228432903]

Mew = [3.6604, -5.0249]

Sigma =[3.1531, -4.7301; -4.7301, 7.1776]

As an attachment there is a mat file containing z_gridvals, etc.

If I just run

clear all

load mvnerror.mat

mvncdf(z_gridvals(1976,:)-z_gridspacing_down(1976,:),z_gridvals(1976,:)+z_gridspacing_up(1976,:),Mew,Sigma)

it is enough to generate the error message described at the beginning of this post.

Side note: these are mostly gpuArrays, not sure if that is in any way relevant (so are aaa1 and aaa2 when created as above, so seems unimportant).

[Matlab Release is R2023a]This error is kind of reproducible but kind of not reproducible. The following is a copy paste that of the output from matlab. Essentially, for a given value of the first two inputs to mvncdf() it throws an error

mvncdf(z_gridvals(1976,:)-z_gridspacing_down(1976,:),z_gridvals(1976,:)+z_gridspacing_up(1976,:),Mew,Sigma)

Error using gpuArray/log

LOG: needs to return a complex result, but this is not supported for real input X on the GPU. Use LOG(COMPLEX(X))

instead.

Error in internal.stats.bvncdf (line 70)

log(t1.*exp(-bsq./(2*asq)) – t2.*sqrt(2*pi).*Phi(-b./a)));

Error in mvncdf (line 249)

y = y + (-1)^i * internal.stats.bvncdf(X, rho, tol/4);

That is the error, but something as minor as the next lines of code being

aaa1=z_gridvals(1976,:)-z_gridspacing_down(1976,:);

aaa2=z_gridvals(1976,:)-z_gridspacing_up(1976,:);

mvncdf(aaa1,aaa2,Mew,Sigma)

ans =

0

and suddenly the error is gone.

This is really weird, because in principle the inputs are the same in both cases.

The values of the four inputs to mvncdf() are as follows (but just putting them in this way does not cause error)

aaa1=[4.546541072119, -19.52465262]

aaa2=[4.548657475153, -17.361228432903]

Mew = [3.6604, -5.0249]

Sigma =[3.1531, -4.7301; -4.7301, 7.1776]

As an attachment there is a mat file containing z_gridvals, etc.

If I just run

clear all

load mvnerror.mat

mvncdf(z_gridvals(1976,:)-z_gridspacing_down(1976,:),z_gridvals(1976,:)+z_gridspacing_up(1976,:),Mew,Sigma)

it is enough to generate the error message described at the beginning of this post.

Side note: these are mostly gpuArrays, not sure if that is in any way relevant (so are aaa1 and aaa2 when created as above, so seems unimportant).

[Matlab Release is R2023a] This error is kind of reproducible but kind of not reproducible. The following is a copy paste that of the output from matlab. Essentially, for a given value of the first two inputs to mvncdf() it throws an error

mvncdf(z_gridvals(1976,:)-z_gridspacing_down(1976,:),z_gridvals(1976,:)+z_gridspacing_up(1976,:),Mew,Sigma)

Error using gpuArray/log

LOG: needs to return a complex result, but this is not supported for real input X on the GPU. Use LOG(COMPLEX(X))

instead.

Error in internal.stats.bvncdf (line 70)

log(t1.*exp(-bsq./(2*asq)) – t2.*sqrt(2*pi).*Phi(-b./a)));

Error in mvncdf (line 249)

y = y + (-1)^i * internal.stats.bvncdf(X, rho, tol/4);

That is the error, but something as minor as the next lines of code being

aaa1=z_gridvals(1976,:)-z_gridspacing_down(1976,:);

aaa2=z_gridvals(1976,:)-z_gridspacing_up(1976,:);

mvncdf(aaa1,aaa2,Mew,Sigma)

ans =

0

and suddenly the error is gone.

This is really weird, because in principle the inputs are the same in both cases.

The values of the four inputs to mvncdf() are as follows (but just putting them in this way does not cause error)

aaa1=[4.546541072119, -19.52465262]

aaa2=[4.548657475153, -17.361228432903]

Mew = [3.6604, -5.0249]

Sigma =[3.1531, -4.7301; -4.7301, 7.1776]

As an attachment there is a mat file containing z_gridvals, etc.

If I just run

clear all

load mvnerror.mat

mvncdf(z_gridvals(1976,:)-z_gridspacing_down(1976,:),z_gridvals(1976,:)+z_gridspacing_up(1976,:),Mew,Sigma)

it is enough to generate the error message described at the beginning of this post.

Side note: these are mostly gpuArrays, not sure if that is in any way relevant (so are aaa1 and aaa2 when created as above, so seems unimportant).

[Matlab Release is R2023a] mvncdf, error MATLAB Answers — New Questions