Class ProbabilityDistribution<T extends Interpretation<PlBeliefSet,PlFormula>>
java.lang.Object
org.tweetyproject.commons.AbstractInterpretation<PclBeliefSet,ProbabilisticConditional>
org.tweetyproject.logics.pcl.semantics.ProbabilityDistribution<T>
- Type Parameters:
T
- The actual interpretation class used for this distribution.
- All Implemented Interfaces:
Map<T,
,Probability> Interpretation<PclBeliefSet,
ProbabilisticConditional>
public class ProbabilityDistribution<T extends Interpretation<PlBeliefSet,PlFormula>>
extends AbstractInterpretation<PclBeliefSet,ProbabilisticConditional>
implements Map<T,Probability>
This class represents a probability distribution on some logical language
- Author:
- Matthias Thimm
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionProbabilityDistribution
(Signature signature) Creates a new probability distribution. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Returns the probability of the given conditionalboolean
containsKey
(Object key) boolean
containsValue
(Object value) static <S extends Interpretation<PlBeliefSet,
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.convexCombination
(double d, ProbabilityDistribution<T> other) Computes the convex combination of this P1 and the given probability distribution P2 with parameter d, i.e.double
entropy()
Returns the entropy of this probability distribution.entrySet()
Returns the signature of the underlying language.static <S extends Interpretation<PlBeliefSet,
PlFormula>>
ProbabilityDistribution<S> getUniformDistribution
(Set<S> interpretations, Signature sig) Returns the uniform distribution on the given interpretations.boolean
isEmpty()
keySet()
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 void
Normalizes the given list of probabilities, i.e.Gets the probability of the given Herbrand interpretation (this is just an alias for get(Object o).Returns the probability of the given formulaput
(T key, Probability value) void
putAll
(Map<? extends T, ? extends Probability> m) boolean
satisfies
(PclBeliefSet beliefBase) Checks whether this interpretation satisfies the given knowledge base.boolean
satisfies
(ProbabilisticConditional formula) Checks whether this interpretation satisfies the given formula.int
size()
toString()
values()
Methods inherited from class org.tweetyproject.commons.AbstractInterpretation
satisfies
Methods inherited from class java.lang.Object
equals, 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
-
Constructor Details
-
ProbabilityDistribution
Creates a new probability distribution.- Parameters:
signature
- the signature
-
-
Method Details
-
getSignature
Returns the signature of the underlying language.- Returns:
- the signature of the underlying language.
-
satisfies
Description copied from interface:Interpretation
Checks whether this interpretation satisfies the given formula.- Specified by:
satisfies
in interfaceInterpretation<PclBeliefSet,
ProbabilisticConditional> - Parameters:
formula
- a formula .- Returns:
- "true" if this interpretation satisfies the given formula.
- Throws:
IllegalArgumentException
- if the formula does not correspond to the expected language.
-
satisfies
Description copied from interface:Interpretation
Checks whether this interpretation satisfies the given knowledge base.- Specified by:
satisfies
in interfaceInterpretation<PclBeliefSet,
ProbabilisticConditional> - Parameters:
beliefBase
- a knowledge base.- Returns:
- "true" if this interpretation satisfies the given knowledge base.
- Throws:
IllegalArgumentException
- IllegalArgumentException if the knowledgebase does not correspond to the expected language.
-
probability
public Probability probability(Interpretation<PlBeliefSet, 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
Returns the probability of the given formula- Parameters:
f
- a formula- Returns:
- a probability.
-
conditionalProbability
Returns the probability of the given conditional- Parameters:
c
- a conditional- Returns:
- a probability.
-
normalize
-
entropy
public double entropy()Returns the entropy of this probability distribution.- Returns:
- the entropy of this probability distribution.
-
convexCombination
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 Interpretation<PlBeliefSet,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 Interpretation<PlBeliefSet,PlFormula>> ProbabilityDistribution<S> getUniformDistribution(Set<S> interpretations, 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.
-
toString
-
clear
public void clear()- Specified by:
clear
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
containsKey
- Specified by:
containsKey
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
containsValue
- Specified by:
containsValue
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
entrySet
- Specified by:
entrySet
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
get
- Specified by:
get
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
put
- Specified by:
put
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
putAll
- Specified by:
putAll
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
remove
- Specified by:
remove
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
size
public int size()- Specified by:
size
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
values
- Specified by:
values
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-
keySet
- Specified by:
keySet
in interfaceMap<T extends Interpretation<PlBeliefSet,
PlFormula>, Probability>
-