Evaluating a Bayesian network
A Bayesian network is a graph of probabilistic dependencies. Nodes in the graph are events, and edges represent conditional dependence. We can build a network from prior knowledge to find out new probabilistic properties of the events.
We will use Haskell's probabilistic functional programming library to evaluate such a network and find interesting probabilities.
Getting ready
Install the probability
library using cabal as follows:
$ cabal install probability
We will be representing the following network. Internalize the following figure to get an intuitive grasp of the variable names:
Event C depends on events A and B. Meanwhile, events D and E depend on event C. Through the power of the Probabilistic Functional Programming library, in this recipe, we will find the probability of event E given only information about event D.
How to do it…
Import the following packages:
import qualified Numeric.Probability.Distribution as Dist import Numeric.Probability.Distribution...