T - The class of the objects used.public class ProbabilityFunction<T extends Comparable<T>> extends Object implements Map<T,Probability>
| Constructor and Description |
|---|
ProbabilityFunction()
Creates a new probability function.
|
ProbabilityFunction(ProbabilityFunction<T> other)
Creates a new probability function by copying the given one.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
static <S extends Comparable<S>> |
convexCombination(double[] factors,
ProbabilityFunction<S>[] creators)
Computes the convex combination of the
given probability distributions P1,...,PN with parameters factors, i.e.
|
ProbabilityFunction<T> |
convexCombination(double d,
ProbabilityFunction<T> other)
Computes the convex combination of this P1 and the
given probability distribution P2 with parameter d, i.e.
|
Set<Map.Entry<T,Probability>> |
entrySet() |
boolean |
equals(Object obj) |
Probability |
get(Object key) |
Vector<Probability> |
getProbabilityVector()
Returns the vector of probabilities, depending on the order
of the domain elements (which can be ordered as they
implement Comparable).
|
Vector<Double> |
getProbabilityVectorAsDoubles()
Returns the vector of probabilities, depending on the order
of the domain elements (which can be ordered as they
implement Comparable).
|
static <S extends Comparable<S>> |
getUniformDistribution(Set<S> objects)
Returns the uniform distribution on the given interpretations.
|
int |
hashCode() |
boolean |
isEmpty() |
boolean |
isNormalized()
Checks whether this probability function is normalized, i.e.
|
Set<T> |
keySet() |
ProbabilityFunction<T> |
linearCombination(double d1,
double d2,
ProbabilityFunction<T> other)
Makes a linear combination of this distribution "p1" and the given distribution "other" and
the given parameters, i.e.
|
void |
normalize()
Normalizes this probability function to have mass 1.
|
protected static void |
normalize(List<Double> probabilities)
Normalizes the given list of probabilities, i.e.
|
Probability |
probability(Collection<? extends T> objects)
Gets the probability of the given object.
|
Probability |
probability(T w)
Gets the probability of the given object.
|
Probability |
put(T key,
Probability value) |
void |
putAll(Map<? extends T,? extends Probability> m) |
Probability |
remove(Object key) |
T |
sample()
Samples one element from the domain of this
probability function, depending on its probability.
|
T |
sample(Random random)
Samples one element from the domain of this
probability function, depending on its probability.
|
int |
size() |
String |
toString() |
Collection<Probability> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic ProbabilityFunction()
public ProbabilityFunction(ProbabilityFunction<T> other)
public Probability probability(T w) throws IllegalArgumentException
w - some object.IllegalArgumentExceptionpublic Probability probability(Collection<? extends T> objects) throws IllegalArgumentException
objects - some object.IllegalArgumentExceptionprotected static void normalize(List<Double> probabilities)
public boolean isNormalized()
public void normalize()
public ProbabilityFunction<T> convexCombination(double d, ProbabilityFunction<T> other)
d - a doubleother - a probability distributionIllegalArgumentException - if either d is not in [0,1] or this and
the given probability distribution are not defined on the same set of interpretations.public ProbabilityFunction<T> linearCombination(double d1, double d2, ProbabilityFunction<T> other)
d1 - a double.d2 - a double.other - a probability distribution.public static <S extends Comparable<S>> ProbabilityFunction<S> convexCombination(double[] factors, ProbabilityFunction<S>[] creators) throws IllegalArgumentException
S - The object classfactors - a vector of doubles.creators - a vector of probability distributions.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 objects, or
the lengths of creators and factors differ.public static <S extends Comparable<S>> ProbabilityFunction<S> getUniformDistribution(Set<S> objects)
S - The interpretation classobjects - set of interpretations of type S.public T sample()
public T sample(Random random)
random - the number generator used.public void clear()
clear in interface Map<T extends Comparable<T>,Probability>public boolean containsKey(Object key)
containsKey in interface Map<T extends Comparable<T>,Probability>public boolean containsValue(Object value)
containsValue in interface Map<T extends Comparable<T>,Probability>public Set<Map.Entry<T,Probability>> entrySet()
entrySet in interface Map<T extends Comparable<T>,Probability>public Probability get(Object key)
get in interface Map<T extends Comparable<T>,Probability>public boolean isEmpty()
isEmpty in interface Map<T extends Comparable<T>,Probability>public Probability put(T key, Probability value)
put in interface Map<T extends Comparable<T>,Probability>public void putAll(Map<? extends T,? extends Probability> m)
putAll in interface Map<T extends Comparable<T>,Probability>public Probability remove(Object key)
remove in interface Map<T extends Comparable<T>,Probability>public int size()
size in interface Map<T extends Comparable<T>,Probability>public Collection<Probability> values()
values in interface Map<T extends Comparable<T>,Probability>public Set<T> keySet()
keySet in interface Map<T extends Comparable<T>,Probability>public int hashCode()
hashCode in interface Map<T extends Comparable<T>,Probability>hashCode in class Objectpublic Vector<Probability> getProbabilityVector()
public Vector<Double> getProbabilityVectorAsDoubles()
public boolean equals(Object obj)
equals in interface Map<T extends Comparable<T>,Probability>equals in class ObjectCopyright © 2018. All rights reserved.