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.199 -3.47 0.000222 0.421 -0.199 Gaussian c(0, 1)
#> 2 1 2 0.142 -3.32 0.000638 0.556 0.142 Gaussian c(0, 1)
#> 3 1 3 2.28 -3.16 0.00161 0.989 2.28 Gaussian c(0, 1)
#> 4 1 4 1.63 -3.01 0.00355 0.949 1.63 Gaussian c(0, 1)
#> 5 1 5 0.547 -2.86 0.00694 0.708 0.547 Gaussian c(0, 1)
#> 6 1 6 0.215 -2.71 0.0121 0.585 0.215 Gaussian c(0, 1)
#> 7 1 7 -1.42 -2.55 0.0193 0.0771 -1.42 Gaussian c(0, 1)
#> 8 1 8 -0.850 -2.40 0.0288 0.198 -0.850 Gaussian c(0, 1)
#> 9 1 9 0.886 -2.25 0.0411 0.812 0.886 Gaussian c(0, 1)
#> 10 1 10 -1.44 -2.10 0.0576 0.0748 -1.44 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 -0.258 -3.24 0.000490 0.398 -0.258 Gaussian c(0, 1)
#> 2 1 2 0.719 -3.12 0.00130 0.764 0.719 Gaussian c(0, 1)
#> 3 1 3 0.720 -2.99 0.00309 0.764 0.720 Gaussian c(0, 1)
#> 4 1 4 -0.697 -2.87 0.00648 0.243 -0.697 Gaussian c(0, 1)
#> 5 1 5 -0.402 -2.75 0.0121 0.344 -0.402 Gaussian c(0, 1)
#> 6 1 6 0.457 -2.63 0.0200 0.676 0.457 Gaussian c(0, 1)
#> 7 1 7 -0.456 -2.50 0.0296 0.324 -0.456 Gaussian c(0, 1)
#> 8 1 8 1.24 -2.38 0.0392 0.893 1.24 Gaussian c(0, 1)
#> 9 1 9 0.183 -2.26 0.0473 0.573 0.183 Gaussian c(0, 1)
#> 10 1 10 0.176 -2.14 0.0532 0.570 0.176 Gaussian c(0, 1)
#> # ℹ 190 more rows