Chapter 1 - The Bayesics: Exercise solutions

Author

Mattias Villani

Click on the arrow to see a solution.

Exercise 1.1

A university uses an automatic tool to detect plagiarism in student essays. The tool has a sensitivity of 0.95 (probability of flagging plagarism when the essay is plagiarized) and a specificity of 0.90 (probability of not flagging plagarism when the essay is not plagiarized). Assume that 1% of all students actually plagiarize. If a student is flagged by the tool, what is the probability that the student actually has plagiarized?

Let \(\mathrm{A}\) be the event that a student has plagiarized and \(\mathrm{B}\) the event that the student is flagged by the tool. We want to compute \(\mathrm{Pr}(A|B)\) given that \(\mathrm{Pr}(B|A)=0.95\), \(\mathrm{Pr}(B^c|A^c)=0.90\) and \(\mathrm{Pr}(A)=0.01\). Using Bayes’ theorem we get \[\begin{align*} \mathrm{Pr}(A|B) =\frac{\mathrm{Pr}(B|A)\mathrm{Pr}(A)}{\mathrm{Pr}(B|A)\mathrm{Pr}(A)+\mathrm{Pr}(B|A^c)\mathrm{Pr}(A^c)} \approx 0.0876. \end{align*}\] Hence, even if the student is flagged by the tool there is still only an 8.76% probability that the student has actually plagiarized.

Exercise 1.2

Think about an event that you are uncertain about, for example the event that you favorite sports team wins their next game. Try to elicit your subjective probability for the event by considering a betting situation where you win $100 if the event occurs. Start with a price of $1 and ask yourself if you would be willing to take the bet. Then gradually increase the price of the bet until you are indifferent between taking the bet or not.

My favorite sports team is the Italian soccer team Napoli. They are playing Juventus at home in Naples next week. I would be willing to pay around $75, but not more,for a bet giving me $100 if Napoli wins. Hence, my subjective probability is around 0.75.

Exercise 1.3

Think about a political party that you care about. Elicit a histogram to represent your prior distribution for the party’s support in percent, \(0\leq \theta \leq 100\), in the next national election, by asking yourself questions about the probability of certain intervals. For example, what is the probability that the party’s support is below 10%? Between 10% and 20%? And so on. Make sure that the final histogram integrates to one over the full support, and plot it.

Exercise 1.4

Reproduce the first row of Figure by writing your own code in your favorite programming language.