Question: After, the preliminary reading above, write the function: def MPE(CPTs,Os) in Python API for Z3 The inputs for MPE are: (1) a list of Conditional

After, the preliminary reading above, write the function: def MPE(CPTs,Os) in Python API for Z3

The inputs for MPE are: (1) a list of Conditional Probability Tables (CPTs) and (2) a list of Observations (Os). Both CPTs and Os have as many number of entries as there are random variables, with the i-th entry in each of the two inputs corresponding to the i-th random variable. We are considering only random variables whose range is a subset of integers.

For some of the random variables their value is observed, and for some it is not. If the value of the i-th random variable was not observed, the i-th entry of Os is None, and if it was observed the i-th entry of Os is the value that was observed.

A Conditional Probability Table (CPT) T is a list of conditional probabilities. Let x be the random variable corresponding to T. A conditional probability in T is encoded as a triplet [Cs,v,p], where p is the probability of the random variable x having value v when the conditions Cs are fulfilled. Cs is a list of conditions and a condition is a pair [rvid,v], where rvid is the index of a random variable y on which x depends when y is set to the value v.

The function MPE returns the most probable explanation for observed values, which will be a list of integers where the i-th entry in the list corresponds to the most probable value of the i-th random variable. You can assume that the inputs are valid, namely:

Given a particular CPT T, you do not have to check that the probabilities in the triplets of T with the same conditions add up to one.

Given a particular CPT T, all the triplets in T use the same random variables in its conditions, i.e., all the conditions in T refer to the same set of rvids.

There are no cycles in the graph induced by CPTs.

Os contains only values from the range of random variables.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!