Generates a set of Gamma distributed values. Can be defined by one and only one of scale, rate or mean. This must be named in the call.

r_gamma(
  shape,
  ...,
  scale = 1,
  rate = NULL,
  mean = NULL,
  n = default_n(shape, scale, rate, mean),
  .seed = NULL
)

Arguments

shape

vector of shape parameters, strictly positive

...

Unused

scale

vector of scale parameters, cannot be specified with rate and mean, strictly positive

rate

vector of rate parameters, cannot be specified with scale and mean, strictly positive

mean

vector of mean parameters, cannot be specified with scale and rate, strictly positive

n

number of observations to generate. The default_n() function will provide a default value within context

.seed

One of the following:

  • NULL (default) will not change the current seed. This is the usual case for generating random numbers.

  • A numeric value. This will be used to set the seed before generating the random numbers. This seed will be stored with the results.

  • TRUE. A random seed value will be generated and set as the seed before the results are generated. Again, this will be stored with the results.

To extract the random seed from a previously generated set of values, use pull_seed()

Value

A numeric vector of length n

Examples

set_n(5) r_gamma(10)
#> [1] 8.434057 11.003641 12.792271 7.427495 8.305949
r_gamma(1:10, scale = 2)
#> [1] 3.0285958 0.7675734 1.2381984 8.0872663 10.4559315 12.3761452 #> [7] 15.2772578 14.3447510 24.5743689 17.4492357
r_gamma(1:10, rate = 1 / 2)
#> [1] 0.833834 4.805072 6.146688 13.619971 9.308173 23.234792 6.562422 #> [8] 11.671311 19.165666 23.249137
r_gamma(1:10, mean = 5)
#> [1] 7.6037200 0.1380241 4.8613137 8.2837324 4.1632452 2.6330293 4.6930505 #> [8] 3.5650226 4.3502901 4.1910517
r_gamma(10, n = 10)
#> [1] 5.691963 11.585059 10.892211 9.797823 10.539044 13.617776 6.439757 #> [8] 9.057051 5.467761 14.489713