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 -2.71 -3.60 0.000353 0.00337 -2.71 Gaussian c(0, 1)
#> 2 1 2 -0.109 -3.46 0.00134 0.456 -0.109 Gaussian c(0, 1)
#> 3 1 3 0.245 -3.32 0.00416 0.597 0.245 Gaussian c(0, 1)
#> 4 1 4 1.79 -3.18 0.0107 0.963 1.79 Gaussian c(0, 1)
#> 5 1 5 0.338 -3.05 0.0226 0.632 0.338 Gaussian c(0, 1)
#> 6 1 6 -0.805 -2.91 0.0397 0.211 -0.805 Gaussian c(0, 1)
#> 7 1 7 -0.829 -2.77 0.0583 0.204 -0.829 Gaussian c(0, 1)
#> 8 1 8 1.37 -2.63 0.0716 0.915 1.37 Gaussian c(0, 1)
#> 9 1 9 -0.0993 -2.50 0.0737 0.460 -0.0993 Gaussian c(0, 1)
#> 10 1 10 -1.18 -2.36 0.0636 0.119 -1.18 Gaussian c(0, 1)
#> # … with 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 2.28 -3.23 0.000450 0.989 2.28 Gaussian c(0, 1)
#> 2 1 2 1.74 -3.09 0.00117 0.959 1.74 Gaussian c(0, 1)
#> 3 1 3 0.346 -2.95 0.00272 0.635 0.346 Gaussian c(0, 1)
#> 4 1 4 0.0875 -2.82 0.00568 0.535 0.0875 Gaussian c(0, 1)
#> 5 1 5 0.719 -2.68 0.0107 0.764 0.719 Gaussian c(0, 1)
#> 6 1 6 -0.970 -2.54 0.0181 0.166 -0.970 Gaussian c(0, 1)
#> 7 1 7 0.932 -2.40 0.0277 0.824 0.932 Gaussian c(0, 1)
#> 8 1 8 -0.519 -2.26 0.0384 0.302 -0.519 Gaussian c(0, 1)
#> 9 1 9 -0.407 -2.13 0.0482 0.342 -0.407 Gaussian c(0, 1)
#> 10 1 10 -0.425 -1.99 0.0556 0.336 -0.425 Gaussian c(0, 1)
#> # … with 190 more rows