Skip to contents

This function takes in a single argument of .x a vector and will return a tibble of information similar to the tidy_ distribution functions. The y column is set equal to dy from the density function.

Usage

tidy_empirical(.x, .num_sims = 1, .distribution_type = "continuous")

Arguments

.x

A vector of numbers

.num_sims

How many simulations should be run, defaults to 1.

.distribution_type

A string of either "continuous" or "discrete". The function will default to "continuous"

Value

A tibble

Details

This function takes in a single argument of .x a vector

Author

Steven P. Sanderson II, MPH

Examples

x <- mtcars$mpg
tidy_empirical(.x = x, .distribution_type = "continuous")
#> # A tibble: 32 × 7
#>    sim_number     x     y    dx       dy     p     q
#>    <fct>      <int> <dbl> <dbl>    <dbl> <dbl> <dbl>
#>  1 1              1  21    2.97 0.000114 0.625  10.4
#>  2 1              2  21    4.21 0.000455 0.625  10.4
#>  3 1              3  22.8  5.44 0.00142  0.781  13.3
#>  4 1              4  21.4  6.68 0.00355  0.688  14.3
#>  5 1              5  18.7  7.92 0.00721  0.469  14.7
#>  6 1              6  18.1  9.16 0.0124   0.438  15  
#>  7 1              7  14.3 10.4  0.0192   0.125  15.2
#>  8 1              8  24.4 11.6  0.0281   0.812  15.2
#>  9 1              9  22.8 12.9  0.0395   0.781  15.5
#> 10 1             10  19.2 14.1  0.0516   0.531  15.8
#> # … with 22 more rows
tidy_empirical(.x = x, .num_sims = 10, .distribution_type = "continuous")
#> # A tibble: 320 × 7
#>    sim_number     x     y    dx        dy      p     q
#>    <fct>      <int> <dbl> <dbl>     <dbl>  <dbl> <dbl>
#>  1 1              1  30.4  1.30 0.0000971 0.938   10.4
#>  2 1              2  30.4  2.59 0.000328  0.938   10.4
#>  3 1              3  21.5  3.89 0.000939  0.719   13.3
#>  4 1              4  22.8  5.19 0.00230   0.781   13.3
#>  5 1              5  30.4  6.48 0.00491   0.938   14.3
#>  6 1              6  15.5  7.78 0.00924   0.281   14.7
#>  7 1              7  21    9.08 0.0156    0.625   14.7
#>  8 1              8  13.3 10.4  0.0242    0.0938  15  
#>  9 1              9  14.7 11.7  0.0342    0.156   15.2
#> 10 1             10  18.1 13.0  0.0444    0.438   15.2
#> # … with 310 more rows