A Unique Way To Visualize Expectations In Probability Theory
From the publisher’s feed, collected in the ZeroLabs newsroom.
The concept of the expected value or the expectation of a random variable plays a central role in probability theory. It is usually interpreted as the average value of the random variable that we expect to see in a large number of independent repetitions of the experiment. It’s a kind of weighted average of all possible values of X, with the weights being the corresponding probabilities. For instance, if X is a nonnegative continuous random variable with density p(x), then:Here, we are taking every possible value x, multiplying it by the amount of probability concentrated near x, and then adding all those contributions together.But there is another interesting way to interpret expectations.Take a fixed nonnegative number, say x = 3.7. Normally, we say that its size is just 3.7. But there is another way to measure 3.7.Imagine a vertical bar of height x, and then imagine sweeping a horizontal level t upward from 0. For every t, we ask: Is t So we define an indicator:For x = 3.7,The area under this graph is exactly 3.7.In general:Now suppose X is a random variable. For every actual outcome, X becomes some fixed positive number. So the identity still holds outcome-by-outcome:Because the integrand is nonnegative, we can swap the expectation and integral(by Tonelli’s theorem):But the expectation of an indicator is just the probability of its event:For a fixed threshold t, P(X > t) is the probability that X survives beyond level t. That is why it is also called the survival function, S(t) = P(X > t).What our above derived formula says is that the expectation of X is nothing but the area under its survival curve.Let’s see our new formula for E[X] in action with an example. SupposeSo X is equally likely to be anywhere between 0 and 1. The usual expectation is E[X]=1/2.For 0 ≤ t ≤ 1,The area under the survival curve, i.e, the area of the triangle is 1/2.This matches with our initial calculation of E[X].Let’s see the discrete version of our formula as well:Now suppose that X takes values in the set {1,2,3,..}.Then the analogous formula is:How? The approach is the same as in the continuous case. In general, for a fixed positive integer n:-Replacing n be a random variable X and taking expectation:Again, since the expectation of an indicator is the probability of its event:-As an example, let X be the number of fair coin flips until the first head. So X = 1, 2, 3, …For X ≥ k, it would mean that the first k-1 flips were tails.Here, the expected waiting time is the sum of the probabilities that the experiment is still alive at each step.A neat geometric visualization for the discrete case is as follows:Let X take values 1, 2, 3, … with pₖ = P(X = k). Using the ordinary definition:-Let’s visualize this double sum as a grid of boxes, with each box at row k having the value pₖ .When X ∈ {1,2,3,4}Each row k holds k boxes, every one equal to pₖ. Adding the values of all the boxes will give us the expectation, and we can add them in two orders.If we do it row-wise, then we are basically using the usual definition:On the other hand, in adding column-wise, we notice that column 1 collects all values that reach threshold 1. In fact, column j collects all values that reach threshold j.Therefore,Note that in all our cases we assumed X as nonnegative. In the case of a general continuous random variable X which can take negative values as well, the expectation formula is:Similarly, for a general integer-valued random variable,References:1) Baxter, Introduction to Probability: Tail Integral Formula.2) UC Berkeley Data 140: Tail Sum Formula.A Unique Way To Visualize Expectations In Probability Theory was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.