View source: R/invgaussian_couplings.R
rinvgaussian | R Documentation |
Parametrized by mu, lambda, with log-density given by
0.5 * log(λ/(2*π)) - 1.5 * log(x) - λ * (x-μ)^2 / (2 * μ^2 * x)
The procedure goes as follows.
Generate nu ~ Normal(0,1).
Define y = nu^2.
Define x = mu + mu^2 * y / (2 * lambda) - mu / (2 * lambda) * sqrt(4 * mu * lambda * y + mu^2 * y^2).
Generate Z ~ Uniform(0,1).
If z <= mu / (mu + x), output x, otherwise output mu^2 / x.
rinvgaussian(n, mu, lambda)
A vector of n draws, where n is the first argument.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.