public class RejectionSampling extends java.lang.Object implements BayesSampleInference
function REJECTION-SAMPLING(X, e, bn, N) returns an estimate of P(X|e)
inputs: X, the query variable
e, observed values for variables E
bn, a Bayesian network
N, the total number of samples to be generated
local variables: N, a vector of counts for each value of X, initially zero
for j = 1 to N do
x <- PRIOR-SAMPLE(bn)
if x is consistent with e then
N[x] <- N[x] + 1 where x is the value of X in x
return NORMALIZE(N)
Figure 14.14 The rejection-sampling algorithm for answering queries given
evidence in a Bayesian Network.| Constructor and Description |
|---|
RejectionSampling() |
RejectionSampling(PriorSample ps) |
| Modifier and Type | Method and Description |
|---|---|
CategoricalDistribution |
ask(RandomVariable[] X,
AssignmentProposition[] observedEvidence,
BayesianNetwork bn,
int N) |
CategoricalDistribution |
rejectionSampling(RandomVariable[] X,
AssignmentProposition[] e,
BayesianNetwork bn,
int Nsamples)
The REJECTION-SAMPLING algorithm in Figure 14.14.
|
public RejectionSampling()
public RejectionSampling(PriorSample ps)
public CategoricalDistribution rejectionSampling(RandomVariable[] X, AssignmentProposition[] e, BayesianNetwork bn, int Nsamples)
X - the query variablese - observed values for variables Ebn - a Bayesian networkNsamples - 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