java.lang.Object
riso.distributions.AbstractDistribution
riso.approximation.DistributionProduct
- All Implemented Interfaces:
- riso.numerical.Callback_nd, riso.distributions.ConditionalDistribution, riso.distributions.Distribution, java.io.Serializable
- public class DistributionProduct
- extends riso.distributions.AbstractDistribution
- implements riso.numerical.Callback_nd
An instance of this class represents a pointwise product of distributions.
Given densities p_1, p_2, p_3,... the density of the product is
p_1(x) p_2(x) p_3(x)....
Such products arise in the computation of the likelihood and posterior for a variable,
since the posterior is proportional to the pointwise product of the likelihood and
the prior, and the likelihood is proportional to the pointwise product of the
likelihood messages.
| Methods inherited from class riso.distributions.AbstractDistribution |
cdf, clone, effective_support, expected_value, get_density, get_nstates, log_p, log_prior, ndimensions_child, ndimensions_parent, p, pretty_input, random, random, set_variable, sqrt_variance, update |
Z
public double Z
distributions
public riso.distributions.Distribution[] distributions
support
public double[][] support
DistributionProduct
public DistributionProduct(boolean is_likelihood,
boolean is_discrete,
riso.distributions.Distribution[] distributions)
throws java.lang.Exception
- Construct a product of distributions.
An attempt is made to find the support of each element in the list of distributions.
In some cases, the attempt will fail -- typically for likelihood functions,
which do not necessarily have bounded support. If at least one element has bounded
support (and we successfully find it), then the normalizing constant Z
is computed.
toString
public java.lang.String toString()
- Return a string which briefly describes this object.
The string is just the list of classes of distributions in this product.
f
public double f(double[] x)
throws java.lang.Exception
- Returns p(x).
- Specified by:
f in interface riso.numerical.Callback_nd
p
public double p(double[] x)
throws java.lang.Exception
- Returns the product (1/Z) prod_{i=0}^{n-1} distributions[i].p(x).
- Specified by:
p in interface riso.distributions.Distribution
ndimensions
public int ndimensions()
- Always returns 1.
- Specified by:
ndimensions in interface riso.distributions.Distribution
format_string
public java.lang.String format_string(java.lang.String leading_ws)
throws java.io.IOException
- Formats a string representation of this distribution.
- Specified by:
format_string in interface riso.distributions.ConditionalDistribution
parse_string
public void parse_string(java.lang.String description)
throws java.io.IOException
- Parse a string containing a description of an instance of this distribution.
The description is contained within curly braces, which are included in the string.
- Specified by:
parse_string in interface riso.distributions.ConditionalDistribution
pretty_output
public void pretty_output(java.io.OutputStream os,
java.lang.String leading_ws)
throws java.io.IOException
- Write an instance of this distribution to an output stream.
initial_mix
public riso.distributions.MixGaussians initial_mix(double[] support)
- Constructs an initial approximation to the product of distributions.
This initial mixture is constructed by obtaining a Gaussian mixture
approximation to each component, then merging the component
approximations. (To ``merge'' several Gaussian mixtures, we just create
another mix containing all the bumps in each input mixture;
the mixing proportion for some bump k in the result
is equal to 1/n a[k] where n is the number of
input mixtures and a[k] is the mixing proportion of the
bump in the mixture it came from.)
- Specified by:
initial_mix in interface riso.distributions.Distribution