Generates a set of Weibull distributed values.

r_weibull(
  shape,
  scale = 1,
  ...,
  b_scale = NULL,
  B_scale = NULL,
  n = default_n(shape, scale, b_scale, B_scale),
  .seed = NULL
)

Arguments

shape

vector of shape parameters, strictly positive

scale

vector of scale parameters, strictly positive

...

Unused

b_scale, B_scale

alternative definition of scale parameter, cannot be provided with scale, 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

Details

This function provides alternative definitions for the scale parameter depending on the user's parametrisation of the Weibull distribution, with \(k\) = shape.

Using \(\lambda\) = scale: $$ F(x) = 1 - exp(-(x/\lambda)^k) $$

Using \(b\) = b_scale: $$ F(x) = 1 - exp(-bx^k) $$

Using \(\beta\) = B_scale: $$ F(x) = 1 - exp(-(\beta x)^k) $$

Examples

set_n(5) r_weibull(10)
#> [1] 0.8865704 1.0200517 1.0958044 1.0260531 0.7680493
r_weibull(1:10, 2)
#> [1] 0.2524544 1.7274966 1.6419339 2.2348380 1.7505143 2.4794669 1.5389722 #> [8] 1.8869082 2.1956387 1.8059748
r_weibull(1:10, scale = 2)
#> [1] 0.8732530 0.5726726 2.1498576 1.6139623 1.7268821 1.7439175 1.8271393 #> [8] 1.3451038 2.1328478 2.0677402
r_weibull(1:10, b_scale = 2)
#> [1] 1.304976 5.681779 4.704802 16.669463 32.375063 65.276567 #> [7] 100.685392 275.002249 526.212190 1025.086852
r_weibull(1:10, B_scale = 2)
#> [1] 1.3303911 0.3637182 0.6763637 0.5326363 0.5965120 0.3347166 0.5281237 #> [8] 0.3356367 0.5074380 0.4914817
r_weibull(10, 2, n = 10)
#> [1] 1.567424 1.676977 1.476552 2.029828 1.627594 2.037763 1.960492 1.957837 #> [9] 1.966667 1.653470