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  30.4  7.23 0.000120 0.938  13.3
#>  2 1              2  14.7  8.29 0.000584 0.156  14.3
#>  3 1              3  18.7  9.34 0.00222  0.469  14.3
#>  4 1              4  19.2 10.4  0.00668  0.531  14.7
#>  5 1              5  24.4 11.5  0.0159   0.812  14.7
#>  6 1              6  17.8 12.5  0.0300   0.406  15  
#>  7 1              7  22.8 13.6  0.0456   0.781  15.2
#>  8 1              8  19.7 14.6  0.0576   0.562  15.2
#>  9 1              9  15.2 15.7  0.0642   0.25   17.3
#> 10 1             10  26   16.7  0.0684   0.844  17.8
#> # ℹ 310 more rows