Random variable and expected valueΒΆ
Aufgabe
Consider a random variable \(X\) with the possible values \(0, 1, 2\) and \(3\). The table shows the probability distribution of \(X\) with \(p_1,p_2\in[0;1]\).
\(k\) |
\(\vert\) |
\(0\) |
\(1\) |
\(2\) |
\(3\) |
---|---|---|---|---|---|
\(P(X=k)\vphantom{1\over2}\) |
\(\vert\) |
\(p_1\vphantom{1\over2}\) |
\(\frac{3}{10}\vphantom{1\over2}\) |
\(\frac{1}{5}\vphantom{1\over2}\) |
\(p_2\vphantom{1\over2}\) |
Demonstrate that the expectation value of \(X\) cannot exceed 2.2.
Solution
The expectation value of a random variable \(X\) is given by the sum over the products of all possible values and their corresponding probabilities:
For the given probabilities, the expectation value becomes
\(p_1\) and \(p_2\) cannot be chosen arbitrarily because all probabilities need to sum up to one:
Furthermore, the probabilities \(p_1\) and \(p_2\) may not be negative, so that \(p_2\) takes on its maximum value for \(p_1=0\). Therefore, the probability \(p_2\) can take values from the interval \([0;\frac{1}{2}]\).
Taking the derivative of the expectation value with respect to the probability \(p_2\)
one finds that the expectation value increases with increasing probability \(p_2\). The maximum of the expectation value is therefore reached for the maximum value of \(p_2\) and is found to agree with the expected value
For the implementation in Sage, we will use \(k\) as an index for
the corresponding probability. \(p_1\) and \(p_2\) defined in
the problem will now be referred to as \(p_0\) and \(p_3\).
In the Sage interface, it is possible to set the values for \(p_1\),
\(p_2\), and \(p_3\) from which \(p_0\) is determined.
At first, we will keep the values set to
\(p_1=\frac{3}{10}\) and \(p_2=\frac{1}{5}\), as specified in
the problem. By changing the value of \(p_3\) in the allowed interval,
we can determine the maximum of the expectation value. By varying the other
probabilities, we can also explore how the maximum of the expectation
value depends on the probabilities fixed in the problem.
We use a parameter eps
to cope with rounding errors which
occur when adding probabilities. The necessity of this parameter
becomes clear by setting it to 0.