
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 -1.53 -4.16 0.000278 0.0632 -1.53 Gaussian c(0, 1)
#> 2 1 2 -3.19 -4.00 0.00108 0.000711 -3.19 Gaussian c(0, 1)
#> 3 1 3 -0.318 -3.84 0.00328 0.375 -0.318 Gaussian c(0, 1)
#> 4 1 4 -0.268 -3.68 0.00784 0.394 -0.268 Gaussian c(0, 1)
#> 5 1 5 2.69 -3.52 0.0147 0.996 2.69 Gaussian c(0, 1)
#> 6 1 6 -0.0990 -3.36 0.0215 0.461 -0.0990 Gaussian c(0, 1)
#> 7 1 7 0.891 -3.20 0.0247 0.813 0.891 Gaussian c(0, 1)
#> 8 1 8 0.382 -3.04 0.0222 0.649 0.382 Gaussian c(0, 1)
#> 9 1 9 0.867 -2.88 0.0157 0.807 0.867 Gaussian c(0, 1)
#> 10 1 10 -0.772 -2.72 0.00873 0.220 -0.772 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.66 -3.59 0.000237 0.952 1.66 Gaussian c(0, 1)
#> 2 1 2 -2.45 -3.46 0.000628 0.00707 -2.45 Gaussian c(0, 1)
#> 3 1 3 -0.0812 -3.33 0.00148 0.468 -0.0812 Gaussian c(0, 1)
#> 4 1 4 0.788 -3.20 0.00308 0.785 0.788 Gaussian c(0, 1)
#> 5 1 5 -0.959 -3.07 0.00573 0.169 -0.959 Gaussian c(0, 1)
#> 6 1 6 0.916 -2.94 0.00947 0.820 0.916 Gaussian c(0, 1)
#> 7 1 7 -1.08 -2.81 0.0140 0.140 -1.08 Gaussian c(0, 1)
#> 8 1 8 -0.0673 -2.68 0.0186 0.473 -0.0673 Gaussian c(0, 1)
#> 9 1 9 -0.301 -2.54 0.0223 0.382 -0.301 Gaussian c(0, 1)
#> 10 1 10 -0.321 -2.41 0.0248 0.374 -0.321 Gaussian c(0, 1)
#> # ℹ 190 more rows