A discrete Bayesian network factorizes the joint distribution into one conditional table per node: P(x) = product_i P(x_i | parents of x_i). This question computes the probability of one full assignment.
Implement joint_probability(x, parents, cpts).
x is a sequence with one integer value per node.parents[i] is a tuple of node indices that are the parents of node i. It is empty for a root.cpts[i] is a NumPy array with one axis per parent (in the order given by parents[i]) followed by a last axis for node i. Each row along the last axis sums to 1.cpts[i][parent values..., x_i] over all nodes, as a float.len(x), len(parents) and len(cpts) must match. Otherwise raise ValueError.len(parents[i]) + 1 raises ValueError.ValueError.ValueError.Build the index for node i as a tuple: the parent values followed by x[i]. Then index the table with that tuple.
No results yet
Run your code to check it against the examples, or submit to run every test.