Mercurial > hg > camir-ismir2012
view toolboxes/FullBNT-1.0.7/KPMstats/cwr_prob.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 [likXandY, likYgivenX, post] = cwr_prob(cwr, X, Y); % CWR_EVAL_PDF cluster weighted regression: evaluate likelihood of Y given X % function [likXandY, likYgivenX, post] = cwr_prob(cwr, X, Y); % % likXandY(t) = p(x(:,t), y(:,t)) % likXgivenY(t) = p(x(:,t)| y(:,t)) % post(c,t) = p(c | x(:,t), y(:,t)) [nx N] = size(X); nc = length(cwr.priorC); if nc == 1 [mu, Sigma] = cwr_predict(cwr, X); likY = gaussian_prob(Y, mu, Sigma); likXandY = likY; likYgivenX = likY; post = ones(1,N); return; end % likY(c,t) = p(y(:,t) | c) likY = clg_prob(X, Y, cwr.muY, cwr.SigmaY, cwr.weightsY); % likX(c,t) = p(x(:,t) | c) [junk, likX] = mixgauss_prob(X, cwr.muX, cwr.SigmaX); likX = squeeze(likX); % prior(c,t) = p(c) prior = repmat(cwr.priorC(:), 1, N); post = likX .* likY .* prior; likXandY = sum(post, 1); post = post ./ repmat(likXandY, nc, 1); %loglik = sum(log(lik)); %loglik = log(lik); likX = sum(likX .* prior, 1); likYgivenX = likXandY ./ likX;