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
#> # ℹ 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  27.3  2.23 0.0000518 0.875   10.4
#>  2 1              2  21    3.51 0.000192  0.625   14.7
#>  3 1              3  27.3  4.80 0.000577  0.875   15  
#>  4 1              4  18.1  6.09 0.00142   0.438   15  
#>  5 1              5  21    7.37 0.00295   0.625   15.2
#>  6 1              6  33.9  8.66 0.00541   1       15.5
#>  7 1              7  18.7  9.94 0.00922   0.469   15.8
#>  8 1              8  22.8 11.2  0.0152    0.781   17.3
#>  9 1              9  10.4 12.5  0.0239    0.0625  17.8
#> 10 1             10  14.7 13.8  0.0347    0.156   18.1
#> # ℹ 310 more rows