Class ProbabilityDistribution<T extends net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,net.sf.tweety.logics.pl.syntax.PlFormula>>
- java.lang.Object
-
- net.sf.tweety.commons.AbstractInterpretation<PclBeliefSet,ProbabilisticConditional>
-
- net.sf.tweety.logics.pcl.semantics.ProbabilityDistribution<T>
-
- 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 Summary
Constructors Constructor Description ProbabilityDistribution(net.sf.tweety.commons.Signature signature)Creates a new probability distribution.
-
Method Summary
Modifier and Type Method Description voidclear()net.sf.tweety.math.probability.ProbabilityconditionalProbability(net.sf.tweety.logics.cl.syntax.Conditional c)Returns the probability of the given conditionalbooleancontainsKey(Object key)booleancontainsValue(Object value)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)Computes the convex combination of the given probability distributions P1,...,PN with parameters factors, i.e.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.doubleentropy()Returns the entropy of this probability distribution.Set<Map.Entry<T,net.sf.tweety.math.probability.Probability>>entrySet()net.sf.tweety.math.probability.Probabilityget(Object key)net.sf.tweety.commons.SignaturegetSignature()Returns the signature of the underlying language.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.booleanisEmpty()Set<T>keySet()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.static voidnormalize(List<Double> probabilities)Normalizes the given list of probabilities, i.e.net.sf.tweety.math.probability.Probabilityprobability(net.sf.tweety.commons.Interpretation<net.sf.tweety.logics.pl.syntax.PlBeliefSet,net.sf.tweety.logics.pl.syntax.PlFormula> w)Gets the probability of the given Herbrand interpretation (this is just an alias for get(Object o).net.sf.tweety.math.probability.Probabilityprobability(net.sf.tweety.logics.pl.syntax.PlFormula f)Returns the probability of the given formulanet.sf.tweety.math.probability.Probabilityput(T key, net.sf.tweety.math.probability.Probability value)voidputAll(Map<? extends T,? extends net.sf.tweety.math.probability.Probability> m)net.sf.tweety.math.probability.Probabilityremove(Object key)booleansatisfies(PclBeliefSet beliefBase)booleansatisfies(ProbabilisticConditional formula)intsize()StringtoString()Collection<net.sf.tweety.math.probability.Probability>values()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
getSignature
public net.sf.tweety.commons.Signature getSignature()
Returns the signature of the underlying language.- Returns:
- the signature of the underlying language.
-
satisfies
public boolean satisfies(ProbabilisticConditional formula) throws IllegalArgumentException
- Specified by:
satisfiesin interfacenet.sf.tweety.commons.Interpretation<PclBeliefSet,ProbabilisticConditional>- Throws:
IllegalArgumentException
-
satisfies
public boolean satisfies(PclBeliefSet beliefBase) throws IllegalArgumentException
- Specified by:
satisfiesin interfacenet.sf.tweety.commons.Interpretation<PclBeliefSet,ProbabilisticConditional>- Throws:
IllegalArgumentException
-
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 IllegalArgumentExceptionGets 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 doubleother- 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()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<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:
containsValuein interfaceMap<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)
-
isEmpty
public boolean isEmpty()
-
put
public net.sf.tweety.math.probability.Probability put(T key, net.sf.tweety.math.probability.Probability value)
-
putAll
public void putAll(Map<? extends T,? extends net.sf.tweety.math.probability.Probability> m)
-
remove
public net.sf.tweety.math.probability.Probability remove(Object key)
-
size
public int size()
-
values
public Collection<net.sf.tweety.math.probability.Probability> values()
-
-