Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/potentials/@cpot/cpot_to_mpot.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 mom = cpot_to_mpot(can) | |
2 % CPOT_TO_MPOT Convert a canonical potential to moment form. | |
3 % mom = cpot_to_mpot(can) | |
4 | |
5 [logp, mu, Sigma] = canonical_to_moment(can.g, can.h, can.K); | |
6 mom = mpot(can.domain, can.sizes, logp, mu, Sigma); | |
7 | |
8 %%%%%%% | |
9 | |
10 function [logp, mu, Sigma] = canonical_to_moment(g, h, K) | |
11 % CANONICAL_TO_MOMENT Convert canonical characteristics to moment form. | |
12 % [logp, mu, Sigma] = canonical_to_moment(g, h, K) | |
13 | |
14 n = length(K); | |
15 if isempty(K) | |
16 logp = g - 0.5*(log(det(K)) - n*log(2*pi)); | |
17 Sigma = []; | |
18 mu = []; | |
19 else | |
20 if det(K)==0 | |
21 Sigma = inf*ones(n,n); | |
22 mu = zeros(n,1); % if the precision is zero, the mean is arbitrary | |
23 logp = g; % the scaling factor for the uniform distribution is 1 | |
24 else | |
25 Sigma = inv(K); | |
26 mu = Sigma*h; | |
27 logp = g - 0.5*(log(det(K)) - n*log(2*pi) - mu'*K*mu); | |
28 end | |
29 end |