annotate toolboxes/FullBNT-1.0.7/KPMstats/condGaussToJoint.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [muXY, SigmaXY] = condGaussToJoint(muX, SigmaX, muY, SigmaY, WYgivenX)
wolffd@0 2
wolffd@0 3 % Compute P(X,Y) from P(X) * P(Y|X) where P(X)=N(X;muX,SigmaX)
wolffd@0 4 % and P(Y|X) = N(Y; WX + muY, SigmaY)
wolffd@0 5
wolffd@0 6 % For details on how to compute a Gaussian from a Bayes net
wolffd@0 7 % - "Gaussian Influence Diagrams", R. Shachter and C. R. Kenley, Management Science, 35(5):527--550, 1989.
wolffd@0 8
wolffd@0 9 % size(W) = dy x dx
wolffd@0 10 dx = length(muX);
wolffd@0 11 dy = length(muY);
wolffd@0 12 muXY = [muX(:); WYgivenX*muX(:) + muY];
wolffd@0 13
wolffd@0 14 W = [zeros(dx,dx) WYgivenX';
wolffd@0 15 zeros(dy,dx) zeros(dy,dy)];
wolffd@0 16 D = [SigmaX zeros(dx,dy);
wolffd@0 17 zeros(dy,dx) SigmaY];
wolffd@0 18
wolffd@0 19 U = inv(eye(size(W)) - W')';
wolffd@0 20 SigmaXY = U' * D * U;
wolffd@0 21
wolffd@0 22