Class LikelihoodSamplingInference

  • All Implemented Interfaces:
    Inference

    public final class LikelihoodSamplingInference
    extends Object
    implements Inference
    An approximate probabilistic inference algorithm for Bayesian networks and Dynamic Bayesian networks, based on Likelihood Sampling.
    See Also:
    Inference
    • Method Detail

      • getQueryLifecycle

        public QueryLifecycle getQueryLifecycle()
        Optional, allowing callers to hook into query lifecycle events, such as begin query and end query.
        Specified by:
        getQueryLifecycle in interface Inference
      • setQueryLifecycle

        public void setQueryLifecycle​(QueryLifecycle value)
        Optional, allowing callers to hook into query lifecycle events, such as begin query and end query.
        Specified by:
        setQueryLifecycle in interface Inference
      • getQueryFunctions

        public QueryFunctionCollection getQueryFunctions()
        Gets the collection of functions to evaluate, after QueryDistributions have been calculated. If required, a query function collection can be dynamically attached or detached. Also note that individual elements can be enabled or disabled on a per query basis.
        Specified by:
        getQueryFunctions in interface Inference
      • setQueryFunctions

        public void setQueryFunctions​(QueryFunctionCollection value)
        Sets the collection of functions to evaluate, after QueryDistributions have been calculated. If required, a query function collection can be dynamically attached or detached. Also note that individual elements can be enabled or disabled on a per query basis.
        Specified by:
        setQueryFunctions in interface Inference
      • query

        public void query​(QueryOptions queryOptions,
                          QueryOutput queryOutput)
                   throws InconsistentEvidenceException
        Calculates a number of distributions, e.g. P(A) and P(B) given the evidence (case data, e.g. row in a database), and if requested the log-likelihood of the data. Each time this method is called the distributions have their values replaced, acting like buffers.

        As well as requesting distributions of the form P(A), P(B) it is also possible to request distributions over a number of variables such as P(A,B).

        If CLGaussian distributions are requested that include instantiated discrete variables, an algorithm may legitimately return mean and covariance values equal to NaN for entries corresponding to inconsistent discrete combinations. For example, if a CLGaussian is requested that includes a discrete variable 'Gender' with states 'Male' and 'Female' and evidence is set to 'Female' then any mean and covariance entries that correspond to 'Male' may be set to NaN. NaN values will always be accompanied by a corresponding zero value in the CLGaussian.getTable().

        Specified by:
        query in interface Inference
        Parameters:
        queryOptions - Options governing which calculations are performed and how.
        queryOutput - Returns any information, in addition to the distributions, that is requested. For example the log-likelihood.
        Throws:
        InconsistentEvidenceException - Raised if inconsistent evidence is detected, or underflow/overflow occurs when calculating queries or the conflict measure. Note that log-likelihood calculations do not raise this exception, but instead report -Infinity or +Infinity.