[R] Inverse gamma

Alberto Monteiro albmont at centroin.com.br
Fri May 18 13:31:19 CEST 2007


Patrick Wang wrote:
> 
> assume I need to generate X from inverse gamma with parameter (k,
>  beta).
> 
> should I generate from Y from gamma(-k, beta),
> 
> then take X=1/Y?
> 
Check the Borg of All Wisdom...
http://en.wikipedia.org/wiki/Inverse-gamma_distribution

Generate Y from gamma(k, 1/beta) (using...
  rgamma(n = number.of.points, shape = k, scale = 1/beta)
... or ...
  rgamma(n = number.of.points, shape = k, rate = beta)
) and take X = 1/Y

(unless your beta is not the rate parameter...)

Alberto Monteiro



More information about the R-help mailing list