view toolboxes/FullBNT-1.0.7/bnt/potentials/@mpot/mpot_to_cpot.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
line wrap: on
line source
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