IAE Academy

GATE DA

Reasoning under uncertainty

Conditional independence, variable elimination and sampling

Reasoning under uncertainty represents a joint distribution compactly with a Bayesian network, uses conditional independence (read off by d-separation) to cut the number of parameters, and answers queries either exactly (enumeration, variable elimination) or approximately (prior, rejection, likelihood-weighting and Gibbs sampling). Typical problems ask you to factorise a joint, count parameters, decide whether two variables are independent given some evidence, run a small elimination or compute a sampling estimate by hand.

3 previous-year questions · 3 solved · 7 practice questions

Probability tools for reasoning

A joint distribution assigns a probability to every full assignment of the variables. Every other quantity is obtained from it by two operations: marginalisation (summing variables out) and conditioning (fixing observed variables and renormalising). Convention: is the probability of given , and is the probability of both.

PRODUCT RULE

Each conditional is defined only when the event it conditions on has positive probability ( for ).

MARGINALISATION (SUM RULE)

Sum over every value of each variable being removed.

BAYES' RULE

Requires . Turns a likelihood into a posterior ; the denominator comes from marginalisation.

CONDITIONING BY NORMALISATION

Requires . Compute the unnormalised values for each , then divide by their sum. is just .

CHAIN RULE OF PROBABILITY

Holds for any distribution and any variable ordering (wherever the conditionals are defined); it is the starting point for the Bayesian-network factorisation.

EXAM TIP

A full joint over binary variables has free numbers. That exponential size is the reason networks, conditional independence and clever inference exist.

Independence and conditional independence

and are independent if learning never changes belief about . They are conditionally independent given if, once is known, learning does not change belief about . Conditional independence is the structural property a Bayesian network encodes.

INDEPENDENCE

Must hold for every pair of values of and ; the last form is for values with .

CONDITIONAL INDEPENDENCE

Must hold for every value of , and with (and for the last form).

Neither property implies the other. Two variables can be dependent marginally yet independent given a third (two effects of a common cause), and independent marginally yet dependent once a third is known (two independent causes of a common effect).

WORKED EXAMPLE

Binary with . Given , and are independent with , , , . Are and independent when is not observed?

Solution
  1. .

  2. , and likewise , so .

  3. , so independence fails for this pair of values; and are dependent, although holds.

Answer: No. They are marginally dependent but conditionally independent given .

Bayesian networks and d-separation

A Bayesian network is a directed acyclic graph with one node per random variable and, for each node , a conditional probability table (CPT) giving its distribution for every assignment of its parents. A node with no parents has an ordinary (prior) table. The graph asserts that each variable is conditionally independent of its non-descendants given its parents (the local Markov property).

FACTORISATION OF THE JOINT IN A BAYESIAN NETWORK

For any choice of CPTs this product is a valid joint distribution, and a joint factorises this way exactly when it satisfies the local Markov property for the DAG. Any joint entry is the product of one CPT entry per node.

NUMBER OF INDEPENDENT CPT PARAMETERS

For all-binary variables this is , compared with for the full joint.

d-separation reads conditional independences from the graph. Look at every undirected path between and , and examine each consecutive triple on it. Let be the middle node and let the evidence set be the observed variables.

Triple

Shape

Blocked when

Open when

Chain

or

is observed

is not observed

Fork (common cause)

is observed

is not observed

Collider (common effect)

and all descendants of are unobserved

or any descendant of is observed

Deciding whether X and Y are d-separated given evidence E

  1. List every undirected path from to (ignore arrow directions when walking; no node repeated on a path).

  2. On each path, classify every consecutive triple as chain, fork or collider, and decide whether it is blocked given .

  3. A path is blocked if at least one of its triples is blocked; a path is open only if all its triples are open.

  4. and are d-separated given if every path is blocked; then holds in every distribution that factorises over the graph.

  5. If some path is open, the graph does not guarantee independence (particular CPT values may still give it by accident).

MARKOV BLANKET

Parents, children and the children's other parents (co-parents). Given its Markov blanket, is conditionally independent of every other variable in the network.

WORKED EXAMPLE

Network with , , , , . Find and the number of free parameters.

Solution
  1. Factorise: .

  2. and .

  3. .

  4. Parameters: has 1, has 2, has 2, total 5 (the full joint needs 7).

Answer: ; the network has 5 free parameters.

EXAM TIP

A collider is the only triple that is blocked by default. Observing the collider, or any descendant of it, opens it: two independent causes become dependent once their common effect is known.

EXAM TIP

Edges need not be causal, and different DAGs can encode the same independences. , and all say exactly , whereas says instead. In general two DAGs encode the same independences exactly when they have the same skeleton (edges ignoring direction) and the same v-structures (colliders with and not adjacent).

Exact inference: enumeration and variable elimination

The inference task: given evidence on some variables, compute the posterior of a query variable . The remaining variables are hidden and must be summed out. Convention: ties in the elimination order are broken alphabetically unless a question gives an order; the final answer does not depend on the order, only the work does.

INFERENCE BY ENUMERATION

Sum the network's joint over all hidden-variable assignments with evidence fixed, then normalise (). Cost is exponential in the number of hidden variables.

Variable elimination avoids repeating work by pushing each sum inwards. A factor is a table over a set of variables (a CPT is a factor). Two operations are used: the pointwise product of factors (multiply entries that agree on shared variables, result over the union of variables) and summing out a variable (add the entries over all its values, result over the remaining variables). Intermediate factors need not be probabilities.

ELIMINATING ONE VARIABLE

Multiply only the factors that mention , then sum out; factors not mentioning are left untouched and can be pulled outside the sum.

Variable elimination procedure

  1. Start with one factor per CPT.

  2. Restrict every factor that mentions an evidence variable to its observed value (that variable disappears from the factor).

  3. Choose an order for the hidden variables (alphabetical unless the question states one).

  4. For each hidden variable in turn: multiply all current factors that contain , sum out, and put the new factor back in the pool.

  5. When only factors over the query variable (and possibly constant factors with no variables) remain, multiply them and normalise to get ; constant factors cancel in the normalisation.

Cost. The largest factor created decides the cost, and it depends on the elimination order. The cost is exponential in the number of variables in the largest factor created (the induced width of the order plus one). On a polytree (no undirected cycles, which includes chains and trees) a good order keeps factors small, so inference is linear in the size of the network (the total size of its CPTs); a bad order on the same network can be much worse. Computing the best order is hard in general, and exact inference in a general Bayesian network is NP-hard.

Pruning. A hidden variable that is not an ancestor of the query or of any evidence variable sums to 1 and can be deleted before starting; applying this repeatedly removes every such variable. Example: in , with query and evidence on , node is irrelevant.

WORKED EXAMPLE

Network with , , , , . Use variable elimination (order , then ) to find .

Solution
  1. Factors: , , .

  2. Eliminate : . and .

  3. Eliminate : .

  4. No evidence, so no normalisation is needed (and confirms the total is 1).

Answer:

EXAM TIP

Do not forget to renormalise when there is evidence: the product of factors after restricting gives , not . Divide by the sum over the values of .

Approximate inference by sampling

When exact inference is too costly, estimate the posterior from random samples. Prior, rejection and likelihood-weighting sampling generate each variable in a topological order (parents before children) from its CPT given the already-sampled parents; Gibbs sampling instead resamples one variable at a time. The estimates are consistent (they converge to the true probability as the number of samples grows) but are only approximations for finite .

Convention for sampling by hand: for a binary variable, draw one random number uniform on and set if , else . Use the given random numbers in order, one per sampled variable, in topological order, unless the question states another rule.

PRIOR (FORWARD) SAMPLING

Each sample is drawn from the full joint, ignoring evidence; counts matching samples out of .

REJECTION SAMPLING

Generate prior samples, discard any that disagree with the evidence, and use the counts among the kept ones (undefined if ). The fraction kept is about , so rare evidence wastes almost all samples.

WORKED EXAMPLE

Network with , , . Evidence . Using the convention above, four samples use the random-number pairs : , , , . Estimate by rejection sampling.

Solution
  1. Sample 1: so ; so . Rejected.

  2. Sample 2: so ; so . Kept, .

  3. Sample 3: so ; so . Kept, .

  4. Sample 4: so ; so . Kept, .

  5. Kept 3 samples, one with : estimate .

Answer: (the exact value is ; four samples is very few).

LIKELIHOOD WEIGHTING

Evidence variables are fixed, not sampled; each sample is weighted by the probability of the evidence given its parents' values in that same sample (a parent may itself be an evidence variable, fixed at its observed value). Non-evidence variables are sampled as usual, so no sample is rejected. The method is consistent because the probability of drawing the non-evidence values times the weight equals .

WORKED EXAMPLE

Network with , , . Evidence . Five likelihood-weighting samples draw from its prior. Estimate and compare with the exact value.

Solution
  1. Weight of a sample is : .

  2. Weight with : . Total weight: .

  3. Estimate .

  4. Exact: , , so . The estimate is off because five samples is small.

Answer: against the exact .

GIBBS SAMPLING: RESAMPLING ONE VARIABLE

All other variables are held at their current values; normalises over the values . Only the CPTs of and of its children are needed, because is independent of everything else given its Markov blanket.

Gibbs sampling procedure (an MCMC method)

  1. Fix the evidence variables at their observed values and give every non-evidence variable an initial value.

  2. Repeatedly pick a non-evidence variable (in a fixed order or at random) and resample it from using the current values of the others.

  3. Each resulting full state is one sample; estimate as the fraction of states with .

WORKED EXAMPLE

Network with , , , , . Evidence ; the current state has . Gibbs sampling now resamples . With what probability is drawn?

Solution
  1. , so .

  2. : . : .

  3. Normalise: .

Answer:

Method

Evidence handled by

Waste

Weakness

Prior sampling

Not used (estimates any event)

None, but evidence is not conditioned on

Cannot give a conditional probability by itself

Rejection sampling

Discarding inconsistent samples

Fraction of samples thrown away, on average

Very inefficient when is small

Likelihood weighting

Fixing evidence and weighting

No samples discarded

Evidence influences only the sampling of variables downstream of it; upstream variables are drawn from their priors, so weights can become tiny when evidence is unlikely

Gibbs sampling

Fixing evidence; resampling each variable given its Markov blanket

No samples discarded

Successive samples are correlated; early samples depend on the starting state

EXAM TIP

In likelihood weighting the evidence variable is never sampled and the weight uses the CPT entry of the evidence given the sampled parents. In rejection sampling you do sample it and then throw the sample away if it differs from the evidence. Mixing these up changes the answer.

EXAM TIP

Gibbs estimates converge to the true posterior when the chain can reach every state; a sufficient condition is that every CPT entry is strictly positive. Early samples are often discarded (burn-in) because they still reflect the arbitrary starting state.

PREVIOUS-YEAR QUESTIONS

3 questions from the DA papers

Try each question first, then open the answer. We placed each question under a topic ourselves; the exam paper does not label topics.

See these papers in full: GATE DA 2025 · GATE DA 2024

GATE 2025 DA Q.26

GATE 2025 · DAQ.26 · 1 mark · MSQ

Which of the following statements is/are correct in a Bayesian network?

  1. (A)

    Variable elimination is an approximate inference algorithm

  2. (B)

    Gibbs sampling is an exact inference algorithm

  3. (C)

    Variable elimination is used to determine conditional probabilities

  4. (D)

    Rejection sampling is an approximate inference algorithm

Answer and solution
See the question in the paper
GATE 2025 DA Q.26: answer and solution

GATE 2024 DA Q.24

GATE 2024 · DAQ.24 · 1 mark · MCQ

Consider five random variables , and whose joint distribution satisfies:

Which ONE of the following statements is FALSE?

  1. (A)

    is conditionally independent of given

  2. (B)

    is conditionally independent of given

  3. (C)

    and are conditionally independent given

  4. (D)

    and are conditionally independent given

Answer and solution
See the question in the paper
GATE 2024 DA Q.24: answer and solution

GATE 2024 DA Q.64

GATE 2024 · DAQ.64 · 2 marks · NAT

Given the following Bayesian Network consisting of four Bernoulli random variables and the associated conditional probability tables:

The value of (rounded off to three decimal places).

GATE 2024 DA question 64: Directed acyclic graph with four nodes U, V, W, Z.Tap to open full size
Figure from the GATE 2024 DA paper. It is part of the question.
Figure description

Directed acyclic graph with four nodes U, V, W, Z. Edges: U→V, U→W, V→Z, W→Z (a diamond with U at the top, V and W in the middle, Z at the bottom). Tables: P(U=0)=0.5, P(U=1)=0.5. P(V=0|U) and P(V=1|U): for U=0 it is 0.5 and 0.5; for U=1 it is 0.5 and 0.5. P(W=0|U) and P(W=1|U): for U=0 it is 1 and 0; for U=1 it is 0 and 1. P(Z=0|V,W) and P(Z=1|V,W): (V=0,W=0) is 0.5 and 0.5; (V=0,W=1) is 1 and 0; (V=1,W=0) is 1 and 0; (V=1,W=1) is 0.5 and 0.5.

Answer and solution
GATE 2024 DA Q.64: answer and solution

PRACTICE

7 questions to test yourself

PRACTICE 11 mark · MCQ

In the Bayesian network with edges , and , which statement is guaranteed by the graph?

  1. (A)

  2. (B)

  3. (C)

    (nothing observed)

  4. (D)

    (nothing observed)

Answer and solution

Answer: (C)

  1. The only path between and is , a collider at .

  2. With nothing observed the collider is blocked, so holds: option C.

  3. Observing opens the collider, so A is false; observing , a descendant of , also opens it, so B is false.

  4. is an open chain when nothing is observed, so and are not guaranteed independent: D is false.

PRACTICE 21 mark · NAT

Five binary variables form a Bayesian network with edges , , and . How many independent parameters are needed to specify all the CPTs?

Answer and solution

Answer:

  1. Each binary node needs parameters.

  2. : 1, : 1, (two binary parents): 4, (one parent): 2, (one parent): 2.

  3. Total (the full joint would need ).

PRACTICE 32 marks · NAT

Network of binary variables with , , , , . Using variable elimination, compute . Give the answer correct to 3 decimal places.

Answer and solution

Answer: (accepted range )

  1. Restrict to : gives , .

  2. Eliminate for each value of : and .

  3. Multiply by the prior: and .

  4. Normalise: .

PRACTICE 41 mark · NAT

Network with , , . Rejection sampling with evidence is run on 2000 independent prior samples. What is the expected number of samples that are kept?

Answer and solution

Answer:

  1. A sample is kept exactly when its value equals the evidence, which has probability .

  2. .

  3. Expected kept samples .

PRACTICE 51 mark · MCQ

A Bayesian network has edges , , , and . What is the Markov blanket of ?

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution

Answer: (B)

  1. Parents of : .

  2. Children of : .

  3. Other parents of the child : ( itself is excluded).

  4. . is a grandchild and is not in the blanket: option B.

PRACTICE 62 marks · NAT

Binary network with edges and : , , , , , . Evidence . In Gibbs sampling the current state has , and is now resampled. With what probability is drawn? Give the answer correct to 3 decimal places.

Answer and solution

Answer: (accepted range )

  1. (child and co-parent ), so .

  2. : . : .

  3. Normalise: .

PRACTICE 72 marks · MSQ

Network with edges , , and . Select all statements that hold in every distribution that factorises over this graph.

  1. (A)

  2. (B)

    (nothing observed)

  3. (C)

  4. (D)

Answer and solution

Answer: (A), (D)

  1. Option A: path is a fork blocked by observed ; path is a collider at unobserved (no observed descendants), blocked. True.

  2. Option B: is an open fork when is unobserved. Not guaranteed.

  3. Option C: observing opens the collider , so and can be dependent. Not guaranteed.

  4. Option D: is blocked by observed , and is blocked by observed . True.

OFFICIAL GATE 2027 SYLLABUS WORDING

Copied from the GATE 2027 syllabus; see all 2027 syllabi.

GATE DA

reasoning under uncertainty topics — conditional independence representation, exact inference through variable elimination, and approximate inference through sampling

Preparing in Kolkata? IAE Academy's course for GATE DA.