Basic Examples (2)
Define a BinomialDistribution where the probability of success is drawn from a BetaDistribution:
Compute the PDF:
Compute the Mean:
Draw random samples from the distribution. Each sample returns the values of k and p:
Generate multiple samples:
Calculate the LogLikelihood of the samples:
Samples with lower values of k are generally produced by samples with lower values of p:
Scope (2)
Graph can be used to generate a dependency graph of the individual random variables. Each edge x → y should be read as "x influences y":
The graph is acyclic:
Sample the distribution and compute the expected value. Note that the coordinates are listed in order of appearance of the symbols:
When a ConditionalProductDistribution is defined using unprotected symbols for the bound variables, they will be replaced with symbols of the form x[i]:
Applications (3)
Define a Normal-inverse-Wishart distribution, which is the conjugate prior to a multivariate normal distribution of unknown mean and covariance:
Draw samples from it:
Draw samples from the posterior predictive distribution:
Properties and Relations (3)
A ParameterMixtureDistribution is the marginal distribution of a ConditionalProductDistribution:
Compute the marginal over k by integrating out p from the PDF of the corresponding ConditionalProductDistribution:
The result is the same:
Possible Issues (3)
The distributions need to be ordered correctly and cannot be circular:
In some cases PDF cannot distinguish between evaluating a single coordinate or threading over multiple coordinates. In the following example, the second argument will be interpreted as a pair of coordinates rather than a single 2×2 coordinate:
In this case, wrap the second argument in a list to remove the ambiguity:
Bound variables should not have definitions at the time of defining a ConditionalProductDistribution, since this can have unexpected results:
Use Clear or Block to make sure p has no value at the moment of definition. After that, the variable will have been localized so that p can be used again:
Neat Examples (3)
Define a function that can compute the Expectation of a ConditionalProductDistribution:
Define a distribution using formal symbols (to ensure they do not get renamed) and compute an expected value:
Check the result with a Monte Carlo simulation: