| conditional.mixture | R Documentation |
For a mixture of distributions that support closed-form conditioning (e.g. MVN), uses Bayes' rule to update the mixing weights:
w_k' \propto w_k f_k(x_{given})
where f_k is the marginal density of component k at the
observed values. The component conditionals are computed via
conditional(component_k, given_indices = ..., given_values = ...).
## S3 method for class 'mixture'
conditional(x, P = NULL, ..., given_indices = NULL, given_values = NULL)
x |
A |
P |
Optional predicate function for MC fallback. |
... |
Additional arguments. |
given_indices |
Integer vector of observed variable indices. |
given_values |
Numeric vector of observed values. |
Falls back to MC realization if P is provided or if any
component does not support given_indices/given_values.
A mixture or empirical_dist object.
# Closed-form conditioning on MVN mixture
m <- mixture(
list(mvn(c(0, 0), diag(2)), mvn(c(3, 3), diag(2))),
c(0.5, 0.5)
)
# Condition on X2 = 1
mc <- conditional(m, given_indices = 2, given_values = 1)
mean(mc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.