| rkgcpp | R Documentation |
A random variable X follows Kolmogorov-Gamma(b,c) distribution, in short KG(b,c), if
X \stackrel{d}{=} \dfrac{1}{2\pi^2}\sum_{k=1}^\infty \dfrac{\epsilon_k}{k^2 + c^2/(4\pi^2)}, \quad \epsilon_k\stackrel{iid}{\sim} Gamma(b,1)
where \stackrel{d}{=} denotes equality in distribution.
The random variate generation is based on alternating series method, a fast and exact method (without infinite sum truncation) implemented in cpp.
This function only supports integer b, which is sufficient for cobin and micobin regression models.
rkgcpp(n, b, c)
n |
The number of samples. |
b |
First parameter, positive integer (1,2,...). Length must be 1 or n. |
c |
Second parameter, real, associated with tilting. Length must be 1 or n. |
It returns n independent Kolmogorov-Gamma(b[i],c[i]) samples. If input b or c is scalar, it is assumed to be length n vector with same entries.
rkgcpp(100, 1, 2)
rkgcpp(100, 1, rnorm(100))
rkgcpp(100, rep(c(1,2),50), rnorm(100))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.