
Combine Multiple Tidy Distributions of Different Types
Source:R/combine-tidy-distributions-tbl.R
tidy_combine_distributions.Rd
This allows a user to specify any n
number of tidy_
distributions that can be combined into a single tibble. This is the preferred
method for combining multiple distributions of different types, for example
a Gaussian distribution and a Beta distribution.
This generates a single tibble with an added column of dist_type that will give the distribution family name and its associated parameters.
See also
Other Multiple Distribution:
tidy_multi_single_dist()
Examples
tn <- tidy_normal()
tb <- tidy_beta()
tc <- tidy_cauchy()
tidy_combine_distributions(tn, tb, tc)
#> # A tibble: 150 × 8
#> sim_number x y dx dy p q dist_type
#> <fct> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 1 1 -0.631 -4.24 0.000239 0.264 -0.631 Gaussian c(0, 1)
#> 2 1 2 0.231 -4.07 0.000741 0.591 0.231 Gaussian c(0, 1)
#> 3 1 3 -0.815 -3.91 0.00197 0.207 -0.815 Gaussian c(0, 1)
#> 4 1 4 -1.17 -3.75 0.00455 0.121 -1.17 Gaussian c(0, 1)
#> 5 1 5 -0.0895 -3.59 0.00910 0.464 -0.0895 Gaussian c(0, 1)
#> 6 1 6 -0.202 -3.42 0.0158 0.420 -0.202 Gaussian c(0, 1)
#> 7 1 7 -2.72 -3.26 0.0238 0.00331 -2.72 Gaussian c(0, 1)
#> 8 1 8 -1.17 -3.10 0.0313 0.122 -1.17 Gaussian c(0, 1)
#> 9 1 9 -1.16 -2.94 0.0361 0.123 -1.16 Gaussian c(0, 1)
#> 10 1 10 -0.730 -2.77 0.0367 0.233 -0.730 Gaussian c(0, 1)
#> # ℹ 140 more rows
## OR
tidy_combine_distributions(
tidy_normal(),
tidy_beta(),
tidy_cauchy(),
tidy_logistic()
)
#> # A tibble: 200 × 8
#> sim_number x y dx dy p q dist_type
#> <fct> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 1 1 1.07 -3.28 0.000211 0.858 1.07 Gaussian c(0, 1)
#> 2 1 2 0.244 -3.11 0.000621 0.596 0.244 Gaussian c(0, 1)
#> 3 1 3 -0.397 -2.95 0.00160 0.346 -0.397 Gaussian c(0, 1)
#> 4 1 4 1.44 -2.78 0.00363 0.925 1.44 Gaussian c(0, 1)
#> 5 1 5 -0.867 -2.62 0.00735 0.193 -0.867 Gaussian c(0, 1)
#> 6 1 6 2.17 -2.45 0.0135 0.985 2.17 Gaussian c(0, 1)
#> 7 1 7 -0.270 -2.28 0.0228 0.394 -0.270 Gaussian c(0, 1)
#> 8 1 8 0.0824 -2.12 0.0367 0.533 0.0824 Gaussian c(0, 1)
#> 9 1 9 -0.748 -1.95 0.0567 0.227 -0.748 Gaussian c(0, 1)
#> 10 1 10 -1.50 -1.79 0.0853 0.0666 -1.50 Gaussian c(0, 1)
#> # ℹ 190 more rows