function bnode = update_ess_noisyfn(bnode, family_marginal)
% UPDATE_ESS_NOISYFN: Update the Expected Sufficient Statistics of a noisyfn node.
% bnode = update_ess_noisyfn(bnode, family_marginal)

% We compute the marginals on each parent separately, because of causal independence.
np = length(bnode.parents);
bnode.num_samples = bnode.num_samples + 1;
l = bnode.num_samples;
% We must change the domain in case this came from a different member of the equiv. class
family_marginal.domain = [bnode.parents bnode.self];
for i=1:np
  p = marginalize_potential(family_marginal, bnode.parents(i));
  bnode.parent_distrib(i,:,l) = p.T(:);
end
p = marginalize_potential(family_marginal, bnode.self);
bnode.self_distrib(:,l) = p.T(:);

% To compute log_likelihood_bnode ...
bnode.counts = bnode.counts + family_marginal.T;
