= Solution
The <WinBUGS> model uses a finite truncation of the reciprocal <prior>. The numbered lines have the following roles:
* Line (1) forms $p_j=(1/j)/H_{5000}$, the normalized prior probability vector on the integer labels $1,\ldots,5000$. The deterministic sum may be declared after its use because the model is declarative.
* Line (2) assigns $N$ that <categorical distribution>. The following observation model treats the supplied value $y=100$ as observed data, rather than as an unknown parameter.
* Line (3) forms observation probabilities $p[j]=1/N$ for $j\leq N$ and zero for $j>N$. For integer $N,j$, the small positive offset in `step(N-j+0.01)` includes the endpoint $j=N$ without depending on the convention at zero. There are exactly $N$ nonzero entries, so this vector sums to one.
Combining that <categorical distribution> observation likelihood with the truncated reciprocal <prior> produces
$$
\boxed{p(N\mid y)\propto N^{-2}\mathbf1_{\{y\leq N\leq5000\}}.}
$$
The <Markov chain Monte Carlo> output approximates this posterior. The actual PDF separates the observation line from the preceding comment; it must remain an active stochastic statement.
Back to article page