Skip to contents

This function generates tidy data from the triangular distribution.

Usage

tidy_triangular(
  .n = 50,
  .min = 0,
  .max = 1,
  .mode = 1/2,
  .num_sims = 1,
  .return_tibble = TRUE
)

Arguments

.n

The number of x values for each simulation.

.min

The minimum value of the triangular distribution.

.max

The maximum value of the triangular distribution.

.mode

The mode (peak) value of the triangular distribution.

.num_sims

The number of simulations to perform.

.return_tibble

A logical value indicating whether to return the result as a tibble. Default is TRUE.

Value

A tibble of randomly generated data.

Details

The function takes parameters for the triangular distribution (minimum, maximum, mode), the number of x values (n), the number of simulations (num_sims), and an option to return the result as a tibble (return_tibble). It performs various checks on the input parameters to ensure validity. The result is a data frame or tibble with tidy data for further analysis.

Author

Steven P. Sanderson II, MPH

Examples

tidy_triangular(.return_tibble = TRUE)
#> # A tibble: 50 × 7
#>    sim_number     x      y       dx      dy      p      q
#>    <fct>      <int>  <dbl>    <dbl>   <dbl>  <dbl>  <dbl>
#>  1 1              1 0.441  -0.155   0.00198 0.389  0.441 
#>  2 1              2 0.332  -0.129   0.00505 0.221  0.332 
#>  3 1              3 0.753  -0.103   0.0117  0.878  0.753 
#>  4 1              4 0.808  -0.0770  0.0247  0.926  0.808 
#>  5 1              5 0.780  -0.0509  0.0478  0.903  0.780 
#>  6 1              6 0.0936 -0.0249  0.0845  0.0175 0.0936
#>  7 1              7 0.564   0.00118 0.137   0.620  0.564 
#>  8 1              8 0.590   0.0272  0.207   0.664  0.590 
#>  9 1              9 0.679   0.0533  0.292   0.794  0.679 
#> 10 1             10 0.743   0.0793  0.388   0.868  0.743 
#> # ℹ 40 more rows