Class ProbabilityDistribution<T extends Interpretation<PlBeliefSet,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:
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 void
clear()
Probability
conditionalProbability(Conditional c)
Returns the probability of the given conditionalboolean
containsKey(java.lang.Object key)
boolean
containsValue(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.double
entropy()
Returns the entropy of this probability distribution.java.util.Set<java.util.Map.Entry<T,Probability>>
entrySet()
Probability
get(java.lang.Object key)
Signature
getSignature()
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.boolean
isEmpty()
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 void
normalize(java.util.List<java.lang.Double> probabilities)
Normalizes the given list of probabilities, i.e.Probability
probability(Interpretation<PlBeliefSet,PlFormula> w)
Gets the probability of the given Herbrand interpretation (this is just an alias for get(Object o).Probability
probability(PlFormula f)
Returns the probability of the given formulaProbability
put(T key, Probability value)
void
putAll(java.util.Map<? extends T,? extends Probability> m)
Probability
remove(java.lang.Object key)
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()
java.lang.String
toString()
java.util.Collection<Probability>
values()
-
Methods inherited from class net.sf.tweety.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: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:
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: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:
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:
toString
in classjava.lang.Object
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValue
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
entrySet
public java.util.Set<java.util.Map.Entry<T,Probability>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
get
public Probability get(java.lang.Object key)
- Specified by:
get
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
put
public Probability put(T key, Probability value)
- Specified by:
put
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
putAll
public void putAll(java.util.Map<? extends T,? extends Probability> m)
- Specified by:
putAll
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
remove
public Probability remove(java.lang.Object key)
- Specified by:
remove
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
values
public java.util.Collection<Probability> values()
- Specified by:
values
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
keySet
public java.util.Set<T> keySet()
- Specified by:
keySet
in interfacejava.util.Map<T extends Interpretation<PlBeliefSet,PlFormula>,Probability>
-
-