Why is the posterior probability for the total number of carts being 60 about 0.006? I’m reading Think Bayes by Downey and exploring the famous locomotive problem. After seeing cart 60 of a train zoom by, I’m trying to determine the posterior probability of there being X carts in the whole train.
Prior to any observations, I assumed that the train has anywhere from 1 to 1000 carts, and each length is equally likely. Now, after seeing cart 60, I know that the train must have at least 60 carts … so shouldn’t the posterior probability of the train having 60 carts be 1/(1000 - 59)?
Instead, posterior distribution in the book shows that the probability is about 0.006. Furthermore, the part of the distribution to the right of this value looks like an inverse relationship. Where does this posterior distribution come from? 
 A: This might make a little more sense when you realise the example if about seeing locomotive number 60 (as in train 60), not car 60 of a single train.
The reason the function is inverse is that observing the number 60 is increasingly less likely the more cars there are. If there were 60 locomotives in the company, the chances of you seeing that locomotive is 1/60. If they have 1000 locomotives, the chances of you seeing number 60 would be 1/1000. So it's not equally likely that they have 60 locomotives as 1000, which your 1/(1000 - 59) calculation would assume.
You can get the distribution shown in the book by performing this calculation. Let's
say we set the probability of 1:59 cars being 0, and then set the probability of each following number to be 1 over that number (so 60 would be 1/60, and 1000 would be 1/1000). 
probs <- c(1:59*0, 1/60:1000)

Then we divide each probability by the sum of the total probabilities in the set to get the relative probability. 
probs <- probs/sum(probs)

plot(1:1000, probs)

And you get the figure from the book.

