• Praktische Grundlagen der Informatik
  • Algorithmen und Datenstrukturen
  • Foundations for Robotic and AI
  • Übersicht Data Science:
  • Data Science / Machine Learning
  • Projekt: Deep Teaching
  • Alte Veranstaltungen:
  • Grundlagen der Informatik (NF)
  • Octave/Matlab Tutorial
  • Game Physik
  • Home
  • Lehre
  • Publikationen
  • Kontakt/Impressum

Expectation¶

Expectation of a discrete random variable¶

The expected value (or expectation) of a discrete random variable is essentially the "long-run average" value of that variable.

Given a discrete random variable $X$ with a probability mass function $P(X)$, the expectation of a function $g(X)$ is defined as:

$$\mathbb{E}[g(X)] = \sum_{x \in \text{Val}(X)} g(x)P(x)$$

Where:

  • $\text{Val}(X)$ is the set of all possible values the random variable $X$ can take.
  • $P(x)$ is the probability that $X = x$.
  • $g(x)$ is a function applied to the value $x$.

The Mean ($\mu$)¶

When the function $g(X)$ is simply the identity $g(X) = X$, the expectation gives us the mean ($\mu$) of the distribution:$$\mu = \mathbb{E}[X] = \sum_{x} x \cdot P(x)$$

Example: Robot Localization on a Grid¶

Imagine a robot is moving in a 1D hallway with 5 discrete cells. Its current probability distribution (the "belief") for its position $X$ is as follows:

Position ($x$) $P(x)$ $x \cdot P(x)$
1 0.05 0.05
2 0.10 0.20
3 0.70 2.10
4 0.10 0.40
5 0.05 0.25
Total 1.00 $\mathbb{E}[X] = 3.0$

To find the expected position of the robot, we calculate the weighted average:

$$\mathbb{E}[X] = (1 \cdot 0.05) + (2 \cdot 0.10) + (3 \cdot 0.70) + (4 \cdot 0.10) + (5 \cdot 0.05)$$

$$\mathbb{E}[X] = 0.05 + 0.20 + 2.10 + 0.40 + 0.25 = \mathbf{3.0}$$

Interpretation: Even though the robot has a small chance of being at any of the 5 positions, its "expected" location is exactly at cell 3. This value acts as the "center of mass" of the probability distribution.

Key Properties of Expectation¶

  • Linearity: $\mathbb{E}[aX + bY] = a\mathbb{E}[X] + b\mathbb{E}[Y]$. This is incredibly useful in robotics for combining different sensor or motion models.
  • Constants: $\mathbb{E}[c] = c$. The expected value of a constant is just the constant itself.
  • Not necessarily a possible value: The expected value of a dice roll is 3.5, even though you can never actually roll a 3.5.

Expectation of a Continuous Random Variable¶

For a continuous random variable $X$, we replace the discrete summation with an integral over the entire domain of $X$. If $p(x)$ is the probability density function (PDF), the expectation of a function $f(X)$ is defined as:

Expectation of a continuous random variable

$$\mathbb{E}[f(X)] = \int_{-\infty}^{\infty} f(x) p(x) \, dx$$

The Mean ($\mu$)¶

Just as in the discrete case, the mean of a continuous distribution is the expected value of the identity function $f(x) = x$:$$\mu = \mathbb{E}[X] = \int_{-\infty}^{\infty} x p(x) \, dx$$

Example: Uniform Distribution (Robot in a Tunnel)¶

Imagine a robot is located somewhere in a 10-meter-long tunnel, and its position is represented by a Uniform Distribution $U(0, 10)$. The probability density function is:

$$p(x) = \begin{cases} \frac{1}{10} & \text{if } 0 \leq x \leq 10 \\ 0 & \text{otherwise} \end{cases}$$

To find the expected position:

$$\mathbb{E}[X] = \int_{0}^{10} x \cdot \frac{1}{10} \, dx$$

Solving the integral:

$$\mathbb{E}[X] = \frac{1}{10} \left[ \frac{1}{2}x^2 \right]_0^{10} = \frac{1}{10} \left( \frac{100}{2} - 0 \right) = \mathbf{5.0}$$

Interpretation: The expected value is the geometric center of the distribution. In robotics, if you have no information other than the boundaries of the environment, the expectation is the "least wrong" guess.

Comparison: Discrete vs. Continuous¶

Feature Discrete Continuous
Operator Summation ($\sum$) Integration ($\int$)
Probability Mass Function (PMF) Density Function (PDF)
Definition $\mathbb{E}[f(x)] = \sum f(x)p(x)$ $\mathbb{E}[f(x)] = \int f(x)p(x) dx$
Total Probability $\sum p(x) = 1$ $\int p(x) dx = 1$
Kontakt/Impressum