comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function can = mpot_to_cpot(mom)
2 % MPOT_TO_CPOT Convert a moment potential to canonical form.
3 % mom = mpot_to_cpot(can)
4
5 [g, h, K] = moment_to_canonical(mom.logp, mom.mu, mom.Sigma);
6 can = cpot(mom.domain, mom.sizes, g, h, K);
7
8 %%%%%%%%%%%
9
10 function [g, h, K] = moment_to_canonical(logp, mu, Sigma)
11 % MOMENT_TO_CANONICAL Convert moment characteristics to canonical form.
12 % [g, h, K] = moment_to_canonical(logp, mu, Sigma)
13
14 K = inv(Sigma);
15 h = K*mu;
16 n = length(K);
17 if isempty(mu)
18 g = logp + 0.5*(log(det(K)) - n*log(2*pi));
19 else
20 g = logp + 0.5*(log(det(K)) - n*log(2*pi) - mu'*K*mu);
21 end