view toolboxes/FullBNT-1.0.7/bnt/potentials/@cpot/Old/cpot_to_mpot.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 mom = cpot_to_mpot(can)
% CPOT_TO_MPOT Convert a canonical potential to moment form.
% mom = cpot_to_mpot(can)

[logp, mu, Sigma] = canonical_to_moment(can.g, can.h, can.K);
mom = mpot(can.domain, can.sizes, logp, mu, Sigma);

%%%%%%%

function [logp, mu, Sigma] = canonical_to_moment(g, h, K)
% CANONICAL_TO_MOMENT Convert canonical characteristics to moment form.
% [logp, mu, Sigma] = canonical_to_moment(g, h, K)

if det(K)==0
  Sigma = inf*size(K);
else
  Sigma = inv(K);
end
mu = Sigma*h;
n = length(mu);
if isempty(mu)
  logp = g - 0.5*(log(det(K)) - n*log(2*pi));
else
  logp = g - 0.5*(log(det(K)) - n*log(2*pi) - mu'*K*mu);
end