7

I can't believe I can't find any information on this, but do variables in Bayesian Networks have to be boolean? Every example I've found in my textbook or online uses T/F variables, but how do I represent a variable that has more than two possible values in a Bayesian network?

For example, I was given the following problem:

We have a bag of three biased coins a, b, and c with probabilities of coming up heads of 20%, 60%, and 80%, respectively. One coin is drawn randomly from the bag (with equal likelihood of drawing each of the three coins), and then the coin is flipped three times to generate the outcomes X1, X2, and X3.

Draw the Bayesian network corresponding to this setup and define the necessary CPTs (Conditional Probability Table).

Can anyone help point me in a direction to get started with this?

user1888863
  • 399
  • 2
  • 9

3 Answers3

3

Bayesian networks support variables that have more than two possible values. Koller and Friedman's "Probabilistic Graphical Models" has examples with larger variable domains.

Usually BNs have discrete random variables (with a finite number of different values). But it's also possible to define them with either countably infinite, or continuous variables. In the latter case, the inference algorithms change considerably, though.

Now that I tried finding some examples online, I have to admit you're correct. They're hard to find. Here is an example that is taken from above book. The variable Grade can take on three different values.

example of a Bayesian network with larger variable domains

ziggystar
  • 28,410
  • 9
  • 72
  • 124
1

Excellent question. Someone already pointed you in the right direction in terms of the specific homework problem, so I won't repeat that; I'll try to add some intuition that might be helpful.

The intuition you need here is that a Bayesian network is nothing more than a visual (graphical) way of representing a set of conditional independence assumptions. So, for example, if X and Z are conditionally independent variables given Y, then you could draw the Bayesian network X → Y → Z. And conversely, the one and only thing that the Bayes net X → Y → Z tells you is that there are three variables (X, Y, Z) and that X and Z are conditionally independent given Y.

Once you understand this, then you realize that anything you could write a conditional independence assumption for, you can draw a Bayes net for, and vice-versa.
i.e., they need not be Boolean at all.

user541686
  • 205,094
  • 128
  • 528
  • 886
  • I think the term "Bayesian network" is not always properly defined. Sometimes the CPTs are included, sometimes it's only about the independence relations. This is one of the problems I encountered when making course material. – ziggystar Feb 21 '22 at 08:15
0

Usually Bayesian Networks are modeled with discrete values for each node, and when these values are known (or values get set by the modeler) then people say a probability distibution factorizes over these values.

I think theoretical frameworks for bayesian networks with continuous values also exist, but they are mathematically more difficult than discrete (maybe only suited for PhDs?)

Furthermore I cannot solve your problem off the top of my head, but maybe try this in R:

library(dplyr)                # loads mutate(), %>% (pipe operator)

Model <- c("Coin a", "Coin b", "Coin c")
Prior <- c(0.2, 0.6, 0.8)
Likelihood <- c(1/3, 1/3, 1/3)

bayes_df <- data.frame(Model=Model, Prior=Prior, Likelihood=Likelihood) 

# posterior probabilities
bayes_df %>%
        mutate(Product = Likelihood * Prior, Posterior = Product/sum(Product)) 

Result

   Model Prior Likelihood Product Posterior
1 Coin a   0.2     0.3333 0.06667     0.125
2 Coin b   0.6     0.3333 0.20000     0.375
3 Coin c   0.8     0.3333 0.26667     0.500

I think the "network" is just 2 bubbles connected with an arrow coin -> pick and the CPT is the numbers from above, but I'm not sure.

knb
  • 9,138
  • 4
  • 58
  • 85