Expected Value of a Discrete Distribution
Explore how to calculate the expected value of discrete distributions in C#, including both fair and weighted cases. Understand the mathematical basis and practical applications with examples, and prepare to address challenges in estimating averages in probabilistic programming.
We'll cover the following...
In the previous lesson, we saw that we could compute a continuous posterior distribution when given a continuous prior and a discrete likelihood function; we hope it is clear how that is useful, but we’d like to switch gears for a moment and look at a different (but also extremely useful) computation: the expected value.
Computing the Expected Value
We’ll start with a quick refresher on how to compute the expected value of a discrete distribution.
You probably already know what expected value of a discrete distribution is; we’ve seen it before in this series. But in case you don’t recall, the basic idea is: suppose we have a distribution of values of a type where we can meaningfully take an average; the “expected value” is the average value of a set of samples as the number of samples gets very large.
A simple example is: what’s the expected value of rolling a standard, fair six-sided die? You could compute it empirically by rolling and dividing by , but that would take a while.
Again, recall that in Dungeons and Dragons, is “roll a fair die times and take the sum”.
We could also compute this without doing any rolling; we’d expect that about of those rolls would be , ...