AllenDowney/ThinkBayes — pull request #3 by jac2130 (2013-10-03 17:31:56+00:00)
Title: adding BayesNet

Dear professor Downey,

I thought that it would be useful to have a class called "BayesNet," which inherits from both, a "DiGraph" class, which is a directed graph in NetworkX and from "Joint", which is your class for joint distributions. Thus, I quickly cooked up such a class, which currently handles binary variables and is encoded according to Pearl's "Noisy-OR" encoding (Pearl 1988). The idea here is that this is a way to quickly build a model of causal relationships between k variables in some system of interest. In particular, I am interested in modeling how people might reason differently about such relationships and how differently structured causal models might be compared in the light of data (I'm following the ideas of cognitive scientists Tom Griffiths and Joshua Tennenbaum). Right now, every independent variable has the same marginal probability 'p', of taking on the value 1, and every caused variable is linked to every one of its causes by the same causal effect parameter "causal_effect". As this is just a quick first try at coding such a thing up, it isn't yet very clean and doesn't yet handle a whole lot (variables are restricted to be binary, independent variables all have the same probability of being 1 and causal effects are all the same). For example, it would be nice to have the possibility of negative causation; what if someone believes that some variables have preventative effects on other variables? Just a beginning, but I'm continuously working on it. If you have any ideas, I'd be greatful!

Johannes