public class GibbsAsk extends java.lang.Object implements BayesSampleInference
function GIBBS-ASK(X, e, bn, N) returns an estimate of P(X|e)
local variables: N, a vector of counts for each value of X, initially zero
Z, the nonevidence variables in bn
x, the current state of the network, initially copied from e
initialize x with random values for the variables in Z
for j = 1 to N do
for each Zi in Z do
set the value of Zi in x by sampling from P(Zi|mb(Zi))
N[x] <- N[x] + 1 where x is the value of X in x
return NORMALIZE(N)
Figure 14.16 The Gibbs sampling algorithm for approximate inference in
Bayesian networks; this version cycles through the variables, but choosing
variables at random also works.| Constructor and Description |
|---|
GibbsAsk() |
GibbsAsk(Randomizer r) |
| Modifier and Type | Method and Description |
|---|---|
CategoricalDistribution |
ask(RandomVariable[] X,
AssignmentProposition[] observedEvidence,
BayesianNetwork bn,
int N) |
CategoricalDistribution |
gibbsAsk(RandomVariable[] X,
AssignmentProposition[] e,
BayesianNetwork bn,
int Nsamples)
The GIBBS-ASK algorithm in Figure 14.16.
|
public GibbsAsk()
public GibbsAsk(Randomizer r)
public CategoricalDistribution gibbsAsk(RandomVariable[] X, AssignmentProposition[] e, BayesianNetwork bn, int Nsamples)
X - the query variablese - observed values for variables Ebn - a Bayesian network specifying joint distribution
P(X1,...,Xn)Nsamples - the total number of samples to be generatedpublic CategoricalDistribution ask(RandomVariable[] X, AssignmentProposition[] observedEvidence, BayesianNetwork bn, int N)
ask in interface BayesSampleInferenceX - the query variables.observedEvidence - observed values for variables E.bn - a Bayes net with variables {X} ∪ E ∪ Y /* Y = hidden
variablesN - the total number of samples to be generated