Class ProbabilityDistribution<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>>

  • Type Parameters:
    T - The actual interpretation class used for this distribution.
    All Implemented Interfaces:
    Map<T,​net.sf.tweety.math.probability.Probability>, net.sf.tweety.commons.Interpretation<PclBeliefSet,​ProbabilisticConditional>

    public class ProbabilityDistribution<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>>
    extends net.sf.tweety.commons.AbstractInterpretation<PclBeliefSet,​ProbabilisticConditional>
    implements Map<T,​net.sf.tweety.math.probability.Probability>
    This class represents a probability distribution on some logical language
    Author:
    Matthias Thimm
    • Constructor Detail

      • ProbabilityDistribution

        public ProbabilityDistribution​(net.sf.tweety.commons.Signature signature)
        Creates a new probability distribution.
        Parameters:
        signature - the signature
    • Method Detail

      • getSignature

        public net.sf.tweety.commons.Signature getSignature()
        Returns the signature of the underlying language.
        Returns:
        the signature of the underlying language.
      • probability

        public net.sf.tweety.math.probability.Probability probability​(net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula> w)
                                                               throws IllegalArgumentException
        Gets the probability of the given Herbrand interpretation (this is just an alias for get(Object o).
        Parameters:
        w - a Herbrand interpretation.
        Returns:
        the probability of the given Herbrand interpretation.
        Throws:
        IllegalArgumentException - if the interpretation has no probability set
      • probability

        public net.sf.tweety.math.probability.Probability probability​(net.sf.tweety.logics.pl.syntax.PlFormula f)
        Returns the probability of the given formula
        Parameters:
        f - a formula
        Returns:
        a probability.
      • conditionalProbability

        public net.sf.tweety.math.probability.Probability conditionalProbability​(net.sf.tweety.logics.cl.syntax.Conditional c)
        Returns the probability of the given conditional
        Parameters:
        c - a conditional
        Returns:
        a probability.
      • normalize

        public static void normalize​(List<Double> probabilities)
        Normalizes the given list of probabilities, i.e. divides each probability by the sum of all probabilities.
        Parameters:
        probabilities - initial list of probabilities
      • entropy

        public double entropy()
        Returns the entropy of this probability distribution.
        Returns:
        the entropy of this probability distribution.
      • convexCombination

        public ProbabilityDistribution<T> convexCombination​(double d,
                                                            ProbabilityDistribution<T> other)
        Computes the convex combination of this P1 and the given probability distribution P2 with parameter d, i.e. it returns a P with P(i)=d P1(i) + (1-d) P2(i) for every interpretation i.
        Parameters:
        d - a double
        other - a probability distribution
        Returns:
        the convex combination of this P1 and the given probability distribution P2 with parameter d.
        Throws:
        IllegalArgumentException - if either d is not in [0,1] or this and the given probability distribution are not defined on the same set of interpretations.
      • linearCombination

        public ProbabilityDistribution<T> linearCombination​(double d1,
                                                            double d2,
                                                            ProbabilityDistribution<T> other)
        Makes a linear combination of this distribution "p1" and the given distribution "other" and the given parameters, i.e. it returns a P with P(i)=d1 P1(i) + d2 P2(i) for every interpretation i. NOTE: P is normalized after combination.
        Parameters:
        d1 - a double.
        d2 - a double.
        other - a probability distribution.
        Returns:
        a probability distribution.
      • convexCombination

        public static <S extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>> ProbabilityDistribution<S> convexCombination​(double[] factors,
                                                                                                                                                                                                               ProbabilityDistribution<S>[] creators)
                                                                                                                                                                                                        throws IllegalArgumentException
        Computes the convex combination of the given probability distributions P1,...,PN with parameters factors, i.e. it returns a P with P(i)=d1 P1(i) + d2 P2(i)+ ... + dN PN(i) for every interpretation i (with d1,...,dN=factors).
        Type Parameters:
        S - The interpretation class
        Parameters:
        factors - a vector of doubles.
        creators - a vector of probability distributions.
        Returns:
        the convex combination of the given distributions with parameters factors.
        Throws:
        IllegalArgumentException - if either the sum of factors d is not in 1, or this and the given probability distributions are not defined on the same set of interpretations, or the lengths of creators and factors differ.
      • getUniformDistribution

        public static <S extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>> ProbabilityDistribution<S> getUniformDistribution​(Set<S> interpretations,
                                                                                                                                                                                                                    net.sf.tweety.commons.Signature sig)
        Returns the uniform distribution on the given interpretations.
        Type Parameters:
        S - The interpretation class
        Parameters:
        interpretations - some interpretations.
        sig - a signature
        Returns:
        the uniform distribution on the given interpretations.
      • clear

        public void clear()
        Specified by:
        clear in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • containsKey

        public boolean containsKey​(Object key)
        Specified by:
        containsKey in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • containsValue

        public boolean containsValue​(Object value)
        Specified by:
        containsValue in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • entrySet

        public Set<Map.Entry<T,​net.sf.tweety.math.probability.Probability>> entrySet()
        Specified by:
        entrySet in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • get

        public net.sf.tweety.math.probability.Probability get​(Object key)
        Specified by:
        get in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • put

        public net.sf.tweety.math.probability.Probability put​(T key,
                                                              net.sf.tweety.math.probability.Probability value)
        Specified by:
        put in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • putAll

        public void putAll​(Map<? extends T,​? extends net.sf.tweety.math.probability.Probability> m)
        Specified by:
        putAll in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • remove

        public net.sf.tweety.math.probability.Probability remove​(Object key)
        Specified by:
        remove in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • size

        public int size()
        Specified by:
        size in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • values

        public Collection<net.sf.tweety.math.probability.Probability> values()
        Specified by:
        values in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>
      • keySet

        public Set<T> keySet()
        Specified by:
        keySet in interface Map<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,​net.sf.tweety.logics.pl.syntax.PlFormula>,​net.sf.tweety.math.probability.Probability>