Probability Tree Diagrams Using D3 and Javascript

Probability Tree Diagram

Conditional Probability and Probability Trees

I include some basic probability theory as part of a Problem Solving Course that I teach to law students. Probability can be a useful skill for law students to learn given that attorneys are often called upon to make decisions in environments of uncertainty.

In teaching my students about Conditional Probability, it is often helpful to create a Conditional Probability Tree diagram like the one pictured above. Probability Tree diagrams can help the students visualize the branching structure of conditional probability.

Conditional Probability and Medical Testing

The structure of the tree was inspired by the way Bayes’ Theorem is used in testing for diseases in medicine. When there is a disease with a low prevalence in the population (say, fewer than 1/100 people have the disease), a positive result on a medical test for the disease sometimes produce surprising, counter-intuitive probabilities as to whether the patient actually has the disease even with a positive result on a highly accurate test.

There is a parallel issue in law involving rare evidence and Bayes’ Theorem. Students often find this concept difficult to learn, and the probability tree can aid in comprehension. I will explain this phenomenon further in a future post.You can click on the “Medical Interpretation” to see a interpretation of the tree along the medical paradigm described.

Code for Basic Probability Tree

Below is the code for a more basic basic probability tree diagram that reads in the data structure and displays a tree. Such a basic diagram is much shorter and lacks much of the functionality of the interactive probability tree. I included the basic source code (rather than the full source code of the demo) below because it is much simpler to understand than the code for the interactive one. This should give the gist of how to create a probability tree diagram using d3 and javascript.

Harry Surden is an Associate Professor of Law at the University of Colorado Law School. His scholarship centers upon intellectual property law with a substantive focus on patents and copyright, information privacy law, legal informatics and legal automation, and the application of computer technology within the legal system. His Twitter is : @Harry Surden