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)

Sigma = inv(K);
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

