diff toolboxes/FullBNT-1.0.7/bnt/potentials/@mpot/mpot_to_cpot.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolboxes/FullBNT-1.0.7/bnt/potentials/@mpot/mpot_to_cpot.m	Tue Feb 10 15:05:51 2015 +0000
@@ -0,0 +1,21 @@
+function can = mpot_to_cpot(mom)
+% MPOT_TO_CPOT Convert a moment potential to canonical form.
+% mom = mpot_to_cpot(can)
+
+[g, h, K] = moment_to_canonical(mom.logp, mom.mu, mom.Sigma);
+can = cpot(mom.domain, mom.sizes, g, h, K);
+
+%%%%%%%%%%%
+
+function [g, h, K] = moment_to_canonical(logp, mu, Sigma)
+% MOMENT_TO_CANONICAL Convert moment characteristics to canonical form.
+% [g, h, K] = moment_to_canonical(logp, mu, Sigma)
+
+K = inv(Sigma);
+h = K*mu;
+n = length(K);
+if isempty(mu)
+  g = logp + 0.5*(log(det(K)) - n*log(2*pi));
+else
+  g = logp + 0.5*(log(det(K)) - n*log(2*pi) - mu'*K*mu);
+end