Skip to contents

# Generate Tidy Data from Triangular Distribution

Source: `R/random-tidy-triangular.R`
`tidy_triangular.Rd`

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.

## See also

Other Continuous Distribution: `tidy_beta()`, `tidy_burr()`, `tidy_cauchy()`, `tidy_chisquare()`, `tidy_exponential()`, `tidy_f()`, `tidy_gamma()`, `tidy_generalized_beta()`, `tidy_generalized_pareto()`, `tidy_geometric()`, `tidy_inverse_burr()`, `tidy_inverse_exponential()`, `tidy_inverse_gamma()`, `tidy_inverse_normal()`, `tidy_inverse_pareto()`, `tidy_inverse_weibull()`, `tidy_logistic()`, `tidy_lognormal()`, `tidy_normal()`, `tidy_paralogistic()`, `tidy_pareto()`, `tidy_pareto1()`, `tidy_t()`, `tidy_uniform()`, `tidy_weibull()`, `tidy_zero_truncated_geometric()`

Other Triangular: `util_triangular_param_estimate()`, `util_triangular_stats_tbl()`

## 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.378  -0.174   0.00273 0.286  0.378
    #>  2 1              2 0.558  -0.146   0.00706 0.609  0.558
    #>  3 1              3 0.267  -0.118   0.0164  0.142  0.267
    #>  4 1              4 0.633  -0.0901  0.0343  0.731  0.633
    #>  5 1              5 0.849  -0.0623  0.0646  0.954  0.849
    #>  6 1              6 0.440  -0.0345  0.110   0.388  0.440
    #>  7 1              7 0.360  -0.00661 0.171   0.259  0.360
    #>  8 1              8 0.352   0.0212  0.242   0.248  0.352
    #>  9 1              9 0.801   0.0491  0.317   0.921  0.801
    #> 10 1             10 0.0944  0.0769  0.392   0.0178 0.0944
    #> # ℹ 40 more rows