powered by
This is not directly related to the Polya-Gamma technique, but it is a nice example of using an alternating sum to generate a random variate.
rks(N=1)
$$f(x) = 8 \sum_{i=1}^\infty (-1)^{n+1} n^2 x e^{-2 n^2 x^2}.$$
We follow Devroye (1986) p. 161 to generate random draws from KS.
X = rks(1000)
Run the code above in your browser using DataLab