
\([U \mid \theta ]\) : sampling the latent variable \(U\)  conditionally on the latent parameters \(\theta \) , where \(U\)  follows the distribution:
\(f_{U \mid \mathbf {X}}(u) \propto u^{n-1}(u+\kappa )^{r \gamma -n} \exp \left\lbrace -\frac{a}{\gamma }(u+\kappa )^{\gamma }\right\rbrace .\) 
Sampling \(U\)  is performed via a MH step with a gamma proposal distribution \(\operatorname{ga}\left(\delta , \delta / u^{[t]}\right)\)  centered at the previous \(U\)  value \(u^{[t]}\)  with a tuning parameter \(\delta \)  controlling the coefficient of variation. An adaptive version of the MH algorithm [1]} without the tuning parameter is also implemented in the package, and proposed with the option adaptive=TRUE. It uses a log-transformation of the random variable \(U\) . Note that the target density (REF ) not being log-concave, ergodicity cannot be proven as in [1]}. Nevertheless, the adaptive version appears to offer superior performance in practice.

\([\tilde{M} \mid U, \theta ]\) : simulating the infinite dimensional process conditionally on the parameters and the latent variable \(U\) .
This is performed using the [3]} algorithm.
According to to Theorem 1 in [4]}, the conditional distribution of \(\tilde{M}\)  is composed of two parts, a part without fixed points of discontinuity \(\tilde{M}^*\)  which can be expressed as an infinite sum of random jumps occurring at random locations and a part with fixed points of discontinuity, or in other words: \(\tilde{M}(s) =\tilde{M}^{*}(s)+\sum _{j=1}^{R_n} J_{j}^{*} \mathbb {I}_{(-\infty ,s]}(\theta _{j}^{*})\)  where the \(\theta _{j}^{*}\) , \(j=1,\ldots ,R_n\)  denote the \(R_n\)  distinct parameters among \(\theta _1,\ldots ,\theta _n\)  and where \((-\infty ,s]=\lbrace x\in \mathbb {R}^n:x_i\le s_i,i=1,\ldots ,n\rbrace \) .
In the infinite sum:
\( \tilde{M}^{*}(s) = \sum _{j=1}^{\infty } J_{j} \mathbb {I}_{(-\infty ,s]}(\vartheta _{j}),\) 
the \(J_j\) s are obtained by inverting the relation \(\xi _j=N(J_j)\) , where \(\xi _1, \xi _2, \ldots \)  are jump times of a standard Poisson process of unit rate, that is \(\xi _{1}, \xi _{2}-\xi _{1}, \ldots \stackrel{\mathrm {iid}}{\sim } \operatorname{ga}(1,1)\) , with
\(N(v)=\frac{a}{\Gamma (1-\gamma )} \int _{v}^{\infty } \mathrm {e}^{-(\kappa +u) x} x^{-(1+\gamma )} \mathrm {d} x,\) 
while the jumps \(\vartheta _{j} = (\vartheta _{j}^{(1)},\ldots ,\vartheta _{j}^{(n)})^\top \)  are sampled from the base measure \(P_0\) .
The jumps \(J_j^*\)  at the
fixed locations \(\theta _j^*\)  are gamma distributed:
\(f_{j}^{*}(v)=\frac{(\kappa +u)^{n_{j}-\gamma }}{\Gamma \left(n_{j}-\gamma \right)} v^{n_{j}-\gamma -1} \mathrm {e}^{-(\kappa +u) v},\) 
where \(n_j\)  are the multiplicities, i.e. the number of \(\theta _j\)  equal to \(\theta _j^*\) .
A fundamental merit of Ferguson
and Klass' representation, compared to similar algorithms, is the fact that the random heights \(J_i\)  are obtained in a descending order.
Therefore, one can
truncate the series in (REF ) at a certain finite index \(Q\)  to be decided via a moment-matching criterion (see sec:momentmatching).
This also guarantees that the
highest jumps are not left out.

\([\theta  \mid \mathbf {X}, \tilde{M}]\) : resampling the latent cluster parameters given the data and the random measure. The support of
the conditional distribution of \(\theta _i\)  are the set of locations
\(\lbrace \bar{\vartheta }_{j}\rbrace _{j=1}^\infty = \lbrace \theta _1^*,\ldots ,\theta _{R_n}^*,\vartheta _1,\ldots \rbrace \)  with associated jump \(\lbrace \bar{J}_{j}\rbrace _{j=1}^\infty = \lbrace J_1^*,\ldots ,J_{R_n}^*,J_1,\ldots \rbrace \)  of \(\tilde{M}\) ,
\(f_{\theta _{i} \mid X_{i}, \tilde{M}}(s) \propto \sum _{j} k\left(X_{i} \mid s\right) \bar{J}_{j} \delta _{\bar{\vartheta }_{j}}(\mathrm {d} s).\) 
Simulating from this conditional distribution when an approximation with a finite number of jumps has been determined is
straightforward: one just needs to evaluate the right-hand side of the expression above and normalise.

Updating the hyperparameters of \(P_0\) . We only put a prior on the hyperparameters for the location parameters, and found this to have a higher impact.
Assuming a priori independence between location and scale parameters of the clusters, the conditional posterior distribution on the hyperparameters given the data and the rest of the parameters only depends on the distinct location parameters.
A simple way to proceed is thus to consider a prior conjugate to the base measure.

