Back to Community
Help port Matlab function to Python

Hi All,

Could someone with access to Matlab port this function to python please?

function [ Y ] = gaussianCnd( rho, U, m )  
X = norminv(U(:, 1:m-1));  
y = norminv(U(:, m));  
irho = inv(rho);  
add = irho(m,m);  
edges =  X * (irho(1:m-1,m) + irho(m,1:m-1)');

H = sqrt(add) * y + edges / (2 * sqrt(add));  
subA = sum((X * irho(1:m-1,1:m-1)) .* X, 2);  
A = subA - edges.^2 / (4 * add);

t1 = exp(-0.5 * A) .* normcdf(H);  
t2 = (2*pi)^(0.5 * (m-1)) * det(rho)^0.5 * sqrt(add);

N = t1 ./ t2;  
D = mvnpdf( X, 0, rho(1:m-1,1:m-1) );

Y = N ./ D;

end  

Best regards,
Aqua

2 responses

Thanks Alan. That looks very useful.