concept cpd in category probabilistic programming

appears as: CPD, CPDs, CPD, A CPD, CPDs, The CPD
Practical Probabilistic Programming

This is an excerpt from Manning's book Practical Probabilistic Programming.

In our example, Size is an enumeration, so this functional form is naturally an explicit specification of probabilities. You can present the CPD of Size given Subject by using a table, as shown in table 4.7. I use a standard form for CPD tables that shows which variable the CPD belongs to and which are the conditioning variables. The conditioning variables go down the left. In this example, there’s just one conditioning variable, Subject, and it’s in the left column. You might imagine a dependency model in which a variable depends on more than one other variable. In this case, all these conditioning variables will go on the left. On the right goes the variable whose CPD is being defined, with a column for each possible value of that variable. So here you have Size, with a column for each possible value Small, Medium, and Large. Then there’s a row in the CPD for each possible value of the conditioning variables. In our case, there are two values, People and Landscape, so there’s a row for each. If you have more than one conditioning variable, there will be a row for every combination of values of those variables. Finally, in the cell in the table corresponding to row i and column j, there’s an entry for the probability that the variable whose CPD is being defined has the value in column j, given that the conditioning variables have the values specified by row i. So, for example, in the cell whose row is People and column is Small, you have P(Size = Small | Subject = People). I’ve given each of these probabilities a label from p1 through p6. These labels are used in the following code snippet; you can use them to cross-reference between the table and the code.

Table 4.7. The form of a CPD of Size given Subject

Subject

Size

Small

Medium

Large

People p1 = P(Size = Small | Subject = People) p2 = P(Size = Medium | Subject = People) p3 = P(Size = Large | Subject = People)
Landscape p4 = P(Size = Small | Subject = Landscape) p5 = P(Size = Medium | Subject = Landscape) p6 = P(Size = Large | Subject = Landscape)

In Figaro, a CPD can be implemented by using a compound element. The compound element specifies precisely how the variable depends on other variables. In chapter 2, you saw that Chain is a general kind of compound element that defines a function from a value of the conditioning variable to an element over the conditioned variable. This function can be anything you like, so Chain is the most general Figaro concept for representing CPDs. But many more specific forms are also available.

Each of the CPDs in this network can be represented in a factor, just like table 10.1. In fact, table 10.1 represents P(Size | Subject), the CPD for Size given Subject in figure 10.1. For example, according to the CPD, P(Size = Small | Subject = People) is 0.25. Accordingly, in table 10.1, the number associated with the row Subject = People, Size = Small is 0.25. Table 10.2, meanwhile, shows the factor corresponding to P(Subject). Because Subject has no parents, there’s only one column for the Subject variable. Finally, table 10.3 shows the factor corresponding to P(Brightness | Subject), which mentions the variables Brightness and Subject.

The first five exercises in this chapter are based on the Bayesian network shown in figure 10.12, which describes part of a baby’s lifecycle. The figure also shows the CPDs for each of the four variables. Solutions to selected exercises are available online at www.manning.com/books/practical-probabilistic-programming.

Figure 10.12. Baby lifecycle Bayesian network

1.  Write each of the CPDs as a factor.

Because BP works on the moral graph, and the moral graph has a clique for every CPD, having CPDs with lots of parents is as much of an issue for BP as it is for VE. In particular, the complexity of BP is exponential in the maximum number of parents of a node. Therefore, you should attempt to decompose these CPDs by using techniques described in section 10.3.2.