I'm trying to draw samples from Gamma distribution but I'm considering the 'scale' argument of rgamma
as a vector because each sample unit has different scale parameters. I'd like to know what is the rule of this function to choose the values of the argument. For example, if I run this:
rgamma(10,shape=1,scale=1:10)
Is it generating rgamma(1,shape=1, scale=10)
,$\ldots$,rgamma(1,shape=1, scale=10)
? Besides that, what if I run this:
rgamma(1,shape=1,scale=1:10)
rgamma(2,shape=1,scale=1:10)
rgamma(11,shape=1,scale=1:3)
Which scale parameter is it choosing for each draw? Could someone help me? Thanks
R has built-in vectorization. What this means for your first questions is that rgamma(10, shape=1, scale=c(1:10))
will generate 10 values, one for each scale parameter.
When the number of rgamma calls is not the same as the length of the vector, like in rgamma(11, shape=1, scale=c(1:3))
, R will recycle the scale values in order until it has 11 scale values of the form c(1,2,3,1,2,3,1,2,3,1,2)
.