AllenDowney / ThinkBayes2

Text and code for the forthcoming second edition of Think Bayes, by Allen Downey.
http://allendowney.github.io/ThinkBayes2/
MIT License
1.8k stars 1.49k forks source link

Chapter 5 Prison Sentences #69

Closed mrclary closed 9 months ago

mrclary commented 11 months ago

@AllenDowney, thanks for your book!

I believe that the answer provided for the average of the time remaining for prison sentences is incorrect.

I think the correct answer is to take the average of the distribution of remaining prison sentence times. For a distribution of prison sentences among existing prisoners that is proportional to the sentence, i.e. $ P(y) ~ y $, the distribution of time remaining, $x$, is $ P(x) = sum_{y=x}^3 P(y)/y $. In other words, the fraction of prisoners with one year (or less) to serve of their sentence is $ P(x=1) = P(y=1) + P(y=2)/2 + P(y=3)/3 $; and between 1-2 years left is $ P(x=2) = P(y=2)/2 + P(y=3)/3$; and between 2-3 years left is $ P(3)/3 $.

Thus the distribution for time remaining is 1/2, 1/3, and 1/6, respectively (which is the reverse of the distribution of sentences). The mean of this distribution, $ sum_x P(x) x $, comes out to 5/3 or 1.67.

What is the reasoning for taking 1/2 of the mean of the sentence distribution, which comes out to 7/6 or 1.17?

AllenDowney commented 11 months ago

Thanks for the question.

Computing the remaining time is an interesting question, but the book asks how long is the sentence being served.

The focus of the question is the update, which depends on the likelihood of observing people with different sentences.

I'll close this issue for now, but let me know if you still think there's an error.

mrclary commented 11 months ago

Computing the remaining time is an interesting question, but the book asks how long is the sentence being served.

The books asks two questions: "What is the probability that they are serving a 3-year sentence? What is the average remaining sentence of the prisoners you observe?"

The focus of the question is the update, which depends on the likelihood of observing people with different sentences.

This is true regarding the first question, but not the second.

If I have misinterpreted "average remaining sentence", could you please clarify?

AllenDowney commented 11 months ago

You're right -- it does ask about remaining sentence. In that case, I think you can take the answer in the book and divide by 2.

But even if that's correct, I think it distracts from the focus of the question, so I'll leave this issue open for now and revise the question when I have a chance.

Thank you!

mrclary commented 11 months ago

I think you can take the answer in the book and divide by 2.

I don't understand why this is the case; can you explain?

AllenDowney commented 11 months ago

If you arrive at random and observe a person serving a sentence of length x, you are equally likely to observe them at any point during their sentence, so the expected remaining time is x/2.

Given the posterior distribution of sentences, we can find the distribution of remaining time by dividing all values by 2.

mrclary commented 11 months ago

@AllenDowney, thanks for your patience. I now see what I did wrong. In the original post I used a discrete distribution for the remaining time, between 1 and y, rather than a continuous distribution between 0 and y. The difference between them is exactly 1/2 and accounts for the difference in our result for the average remaining time: 1.67 vs 1.17.

AllenDowney commented 9 months ago

I'm glad you were able to track it down!