Create a mixture distribution.
Usage
mix(..., weights = 1, na.rm = FALSE)
is_mix(object)
is.mix(object)
Arguments
- ...
Distribution objects, or lists of distributions.
- weights
Vector of weights corresponding to the distributions;
or, single numeric for equal weights.
- na.rm
Remove NA
distributions and NA
weights? TRUE
if yes;
default is FALSE
.
- object
Object to be tested
Value
A mixture distribution – an empty distribution if any weights
are NA
and na.rm = FALSE
, the default.
Examples
a <- distionary::dst_norm(0, 1)
b <- distionary::dst_norm(5, 2)
m1 <- mix(a, b, weights = c(1, 4))
#plot(m1)
distionary::variable(m1)
#> [1] "continuous"
c <- distionary::dst_empirical(0:6)
m2 <- mix(a, b, c, weights = c(0.2, 0.5, 0.3))
#plot(m2, n = 1001)
distionary::variable(m2)
#> [1] "mixed"