Lab 2: 🐙 Paul the Octopus
Probability and Statistics

Exercise 1
Octopus Paul tried 14 times to guess the winner of a soccer match. 12 times he guessed correctly, 2 times he guessed wrong. We want to test a hypothesis:
- \(H_0\): the octopus guesses the winner of the match with probability 0.5
- \(H_1\): the octopus picks the winner of the match with probability \(\neq\) 0.5
You must develop a statistical criterion to test this hypothesis and calculate the \(p\)-value.
- \(H_0: p = 0.5\)
- \(H_1: p \neq 0.5\)
- \(S(X) = \sum\limits_{i=1}^n X_i \sim Binom(n, 0.5)\) if hypothesis \(H_0\) is true.
- Criterion: \(\bigl\{ S(X) \gt u_{1-\frac{\alpha}{2}} \bigr\} \cup \bigl\{ S(X) \lt u_{\frac{\alpha}{2}} \bigr\}\), where \(u_{\beta}\) is the critical value equal to the \(\beta\)-quantile of \(Binom(n, 0.5)\),
- \(p\)-value = \(2 \cdot \text{min}\bigl[P\bigl( S(X) \geqslant S_0 \, \, H_0\bigr), \, P\bigl( S(X) \leqslant S_0 \, \, H_0\bigr), \, P\bigl( S(X) \leqslant S_0 \, \, H_0\bigr)) \bigr]\), where \(S_0\) is the value of a statistic from a given sample.
Implement the check_paul_criterion(n, k, alpha) function, where:
n— the number of matches;k— the number of correct predictions from the octopus;alpha— the significance level of the criterion.
The function should return PaulCheckResults with the fields:
is_rejected: whether or not hypothesis \(H_0\) was rejected at significance level \(\alpha\)pvalue: the \(p\)-value of the test
Exercise 2
What conclusions can be drawn from the result obtained in Exercise 1?
Exercise 3
Determine the criterion’s critical region for a given number of matches and a given significance level.
Visualize the critical region of the criterion.
Exercise 4
Construct a confidence interval for the probability of the octopus guessing the winner of the match.