To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _FullBNT / BNT / CPDs / @gaussian_CPD / gaussian_CPD_params_given_dps.m @ 8:b5b38998ef3b

History | View | Annotate | Download (895 Bytes)

1
function [m, C, W] = gaussian_CPD_params_given_dps(CPD, domain, evidence)
2
% GAUSSIAN_CPD_PARAMS_GIVEN_EV_ON_DPS Extract parameters given evidence on all discrete parents
3
% function [m, C, W] = gaussian_CPD_params_given_ev_on_dps(CPD, domain, evidence)
4

    
5
ps = domain(1:end-1);
6
dps = ps(CPD.dps);
7
if isempty(dps)
8
  m = CPD.mean;
9
  C = CPD.cov;
10
  W = CPD.weights;
11
else
12
  odom = domain(~isemptycell(evidence(domain)));
13
  dops = myintersect(dps, odom);
14
  dpvals = cat(1, evidence{dops});
15
  if length(dops) == length(dps)
16
    dpsizes = CPD.sizes(CPD.dps);
17
    dpval = subv2ind(dpsizes, dpvals(:)');
18
    m = CPD.mean(:, dpval);
19
    C = CPD.cov(:, :, dpval);
20
    W = CPD.weights(:, :, dpval);
21
  else
22
    map = find_equiv_posns(dops, dps);
23
    index = mk_multi_index(length(dps), map, dpvals);
24
    m = CPD.mean(:, index{:});
25
    C = CPD.cov(:, :, index{:});
26
    W = CPD.weights(:, :, index{:});
27
  end
28
end