about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMstats/condGaussToJoint.m
diff options
context:
space:
mode:
Diffstat (limited to 'sourcecodes/bnt-master/KPMstats/condGaussToJoint.m')
-rw-r--r--sourcecodes/bnt-master/KPMstats/condGaussToJoint.m22
1 files changed, 22 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/KPMstats/condGaussToJoint.m b/sourcecodes/bnt-master/KPMstats/condGaussToJoint.m
new file mode 100644
index 00000000..59075675
--- /dev/null
+++ b/sourcecodes/bnt-master/KPMstats/condGaussToJoint.m
@@ -0,0 +1,22 @@
+function [muXY, SigmaXY] = condGaussToJoint(muX, SigmaX, muY, SigmaY, WYgivenX)
+
+% Compute P(X,Y) from P(X) * P(Y|X) where P(X)=N(X;muX,SigmaX) 
+% and P(Y|X) = N(Y; WX + muY, SigmaY)
+
+% For details on how to compute a Gaussian from a Bayes net
+% - "Gaussian Influence Diagrams", R. Shachter and C. R. Kenley, Management Science, 35(5):527--550, 1989.
+
+% size(W) = dy x dx
+dx = length(muX);
+dy = length(muY);
+muXY = [muX(:); WYgivenX*muX(:) + muY];
+
+W = [zeros(dx,dx) WYgivenX';
+     zeros(dy,dx) zeros(dy,dy)];
+D = [SigmaX       zeros(dx,dy);
+     zeros(dy,dx) SigmaY];
+
+U = inv(eye(size(W)) - W')';
+SigmaXY = U' * D * U;
+
+