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:
java.util.Map<T,Probability>,Interpretation<PclBeliefSet,ProbabilisticConditional>
public class ProbabilityDistribution<T extends Interpretation<PlBeliefSet,PlFormula>> extends AbstractInterpretation<PclBeliefSet,ProbabilisticConditional> implements java.util.Map<T,Probability>
This class represents a probability distribution on some logical language- Author:
- Matthias Thimm
-
-
Constructor Summary
Constructors Constructor Description ProbabilityDistribution(Signature signature)Creates a new probability distribution.
-
Method Summary
Modifier and Type Method Description voidclear()ProbabilityconditionalProbability(Conditional c)Returns the probability of the given conditionalbooleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.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.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.java.util.Set<java.util.Map.Entry<T,Probability>>entrySet()Probabilityget(java.lang.Object key)SignaturegetSignature()Returns the signature of the underlying language.static <S extends Interpretation<PlBeliefSet,PlFormula>>
ProbabilityDistribution<S>getUniformDistribution(java.util.Set<S> interpretations, Signature sig)Returns the uniform distribution on the given interpretations.booleanisEmpty()java.util.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(java.util.List<java.lang.Double> probabilities)Normalizes the given list of probabilities, i.e.Probabilityprobability(Interpretation<PlBeliefSet,PlFormula> w)Gets the probability of the given Herbrand interpretation (this is just an alias for get(Object o).Probabilityprobability(PlFormula f)Returns the probability of the given formulaProbabilityput(T key, Probability value)voidputAll(java.util.Map<? extends T,? extends Probability> m)Probabilityremove(java.lang.Object key)booleansatisfies(PclBeliefSet beliefBase)Checks whether this interpretation satisfies the given knowledge base.booleansatisfies(ProbabilisticConditional formula)Checks whether this interpretation satisfies the given formula.intsize()java.lang.StringtoString()java.util.Collection<Probability>values()-
Methods inherited from class org.tweetyproject.commons.AbstractInterpretation
satisfies
-
-
-
-
Constructor Detail
-
ProbabilityDistribution
public ProbabilityDistribution(Signature signature)
Creates a new probability distribution.- Parameters:
signature- the signature
-
-
Method Detail
-
getSignature
public Signature getSignature()
Returns the signature of the underlying language.- Returns:
- the signature of the underlying language.
-
satisfies
public boolean satisfies(ProbabilisticConditional formula) throws java.lang.IllegalArgumentException
Description copied from interface:InterpretationChecks whether this interpretation satisfies the given formula.- Specified by:
satisfiesin interfaceInterpretation<PclBeliefSet,ProbabilisticConditional>- Parameters:
formula- a formula .- Returns:
- "true" if this interpretation satisfies the given formula.
- Throws:
java.lang.IllegalArgumentException- if the formula does not correspond to the expected language.
-
satisfies
public boolean satisfies(PclBeliefSet beliefBase) throws java.lang.IllegalArgumentException
Description copied from interface:InterpretationChecks whether this interpretation satisfies the given knowledge base.- Specified by:
satisfiesin interfaceInterpretation<PclBeliefSet,ProbabilisticConditional>- Parameters:
beliefBase- a knowledge base.- Returns:
- "true" if this interpretation satisfies the given knowledge base.
- Throws:
java.lang.IllegalArgumentException- IllegalArgumentException if the knowledgebase does not correspond to the expected language.
-
probability
public Probability probability(Interpretation<PlBeliefSet,PlFormula> w) throws java.lang.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:
java.lang.IllegalArgumentException- if the interpretation has no probability set
-
probability
public Probability probability(PlFormula f)
Returns the probability of the given formula- Parameters:
f- a formula- Returns:
- a probability.
-
conditionalProbability
public Probability conditionalProbability(Conditional c)
Returns the probability of the given conditional- Parameters:
c- a conditional- Returns:
- a probability.
-
normalize
public static void normalize(java.util.List<java.lang.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:
java.lang.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 java.lang.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:
java.lang.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(java.util.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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValuein interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
entrySet
public java.util.Set<java.util.Map.Entry<T,Probability>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
get
public Probability get(java.lang.Object key)
- Specified by:
getin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
put
public Probability put(T key, Probability value)
- Specified by:
putin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
putAll
public void putAll(java.util.Map<? extends T,? extends Probability> m)
- Specified by:
putAllin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
remove
public Probability remove(java.lang.Object key)
- Specified by:
removein interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
values
public java.util.Collection<Probability> values()
- Specified by:
valuesin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
keySet
public java.util.Set<T> keySet()
- Specified by:
keySetin interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
-