Probability theory: The Law Of Total Probability

This is part of the course “Probability Theory and Statistics for Programmers”.

Image for post
Image for post
Probability Theory For Programmers

Let it be required to determine the probability of the event A, which can occur with one of the events H1, H2,…, Hn forming a complete group of mutually exclusive events. This is “The Law Of Total Probability”:

Image for post
Image for post
Law of total probability

In order to show how this concept works, we will represent events like a tree. Let’s imagine that we want to calculate the probability of some event A1.

Image for post
Image for post

Let’s calculate the probability of the event A1 using the previous formula:

Image for post
Image for post
probability of A1

Now we can write a function which will take the tree of probabilities and name of the event and will return probability. We will represent root as the list of trees and will walk recursively through those trees calculating probability on the way.

Next part ->

Reach the next level of focus and productivity with increaser.org.

Image for post
Image for post
Increaser

Written by

Software engineer, creator of increaser.org. More at geekrodion.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store