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.
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"
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 33.9 4.28 0.000275 1 10.4
#> 2 1 2 10.4 5.43 0.00127 0.0625 10.4
#> 3 1 3 26 6.59 0.00428 0.844 10.4
#> 4 1 4 21.4 7.74 0.0105 0.688 10.4
#> 5 1 5 15.2 8.89 0.0190 0.25 14.3
#> 6 1 6 21.4 10.0 0.0260 0.688 15.2
#> 7 1 7 10.4 11.2 0.0294 0.0625 15.2
#> 8 1 8 21.5 12.4 0.0326 0.719 15.2
#> 9 1 9 15.5 13.5 0.0405 0.281 15.5
#> 10 1 10 21.5 14.7 0.0509 0.719 15.5
#> # ℹ 310 more rows