0

This question is very closely related to posts here and also here.

Let's say that random variable X = Gamma(k, theta), and I am interested in simulating Y, where Y = log(X).

Could you suggest R-package which allows to do it (or suggest an R-code)? Thank you very much in advance!

Community
  • 1
  • 1
user36478
  • 346
  • 6
  • 14

1 Answers1

3

If you need to extract Y samples, just try:

#set the number of samples
n<-10000
Y<-log(rgamma(n,k,theta))

Then, for instance, you can hist(Y) to see the distribution.

nicola
  • 24,005
  • 3
  • 35
  • 56
  • Thank you! But then I would like to ask a related question -- can we say that density of Y is simply log (dgamma(n, k, theta) ) ? – user36478 Jul 23 '15 at 08:42
  • No, you cannot. The first link you provided answers to this question. – nicola Jul 23 '15 at 08:49
  • Exactly, thank you again, and would like to ask the last (naive) question that may help to solve (find examples in R) this question when using different distributions. When X ~ Gamma and Y = exp(X), then Y follows log-Gamma distribution. How do we call distribution when Y = log(X), i.e. what is a general name? – user36478 Jul 23 '15 at 09:26