public class ProbabilityTable extends java.lang.Object implements CategoricalDistribution, Factor
| Modifier and Type | Class and Description |
|---|---|
static interface |
ProbabilityTable.Iterator
Interface to be implemented by an object/algorithm that wishes to iterate
over the possible assignments for the random variables comprising this
table.
|
| Constructor and Description |
|---|
ProbabilityTable(java.util.Collection<RandomVariable> vars) |
ProbabilityTable(double[] vals,
RandomVariable... vars) |
ProbabilityTable(RandomVariable... vars) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(RandomVariable rv) |
CategoricalDistribution |
divideBy(CategoricalDistribution divisor)
Divide the dividend (this) CategoricalDistribution by the divisor to
create a new CategoricalDistribution representing the quotient.
|
ProbabilityTable |
divideBy(ProbabilityTable divisor) |
java.util.Set<RandomVariable> |
getArgumentVariables() |
java.util.Set<RandomVariable> |
getFor() |
int |
getIndex(java.lang.Object... assignments)
Retrieve the index into the CategoricalDistribution for the provided set
of values for the random variables comprising the Distribution.
|
double |
getSum() |
double |
getValue(AssignmentProposition... assignments)
Get the value for the provided set of AssignmentPropositions for the
random variables comprising the Distribution (size of each must equal and
their random variables must match).
|
double |
getValue(java.lang.Object... assignments)
Get the value for the provided set of values for the random variables
comprising the Distribution (ordering and size of each must equal and
their domains must match).
|
double[] |
getValues()
Note: Do not modify the double[] returned by this method directly.
|
void |
iterateOver(CategoricalDistribution.Iterator cdi)
Iterate over all the possible value assignments for the Random Variables
comprising this CategoricalDistribution.
|
void |
iterateOver(CategoricalDistribution.Iterator cdi,
AssignmentProposition... fixedValues)
Iterate over all possible values assignments for the Random Variables
comprising this CategoricalDistribution that are not in the fixed set of
values.
|
void |
iterateOver(Factor.Iterator fi)
Iterate over all the possible value assignments for the Random Variables
comprising this Factor.
|
void |
iterateOver(Factor.Iterator fi,
AssignmentProposition... fixedValues)
Iterate over all possible values assignments for the Random Variables
comprising this Factor that are not in the fixed set of values.
|
void |
iterateOverTable(ProbabilityTable.Iterator pti)
Iterate over all the possible value assignments for the Random Variables
comprising this ProbabilityTable.
|
void |
iterateOverTable(ProbabilityTable.Iterator pti,
AssignmentProposition... fixedValues)
Iterate over all possible values assignments for the Random Variables
comprising this ProbabilityTable that are not in the fixed set of values.
|
CategoricalDistribution |
marginal(RandomVariable... vars)
Get the marginal probability for the provided variables from this
Distribution creating a new Distribution of the remaining variables with
their values updated with the summed out random variables.
see: AIMA3e page 492. |
CategoricalDistribution |
multiplyBy(CategoricalDistribution multiplier)
Multiplication of this Distribution by a given multiplier, creating a new
Distribution representing the product of the two.
|
CategoricalDistribution |
multiplyByPOS(CategoricalDistribution multiplier,
RandomVariable... prodVarOrder)
Multiplication - Product Order Specified (POS).
|
ProbabilityTable |
normalize()
Normalize the values comprising this distribution.
|
Factor |
pointwiseProduct(Factor multiplier)
Pointwise multiplication of this Factor by a given multiplier, creating a
new Factor representing the product of the two.
see: AIMA3e Figure 14.10 page 527. Note: Default Factor multiplication is not commutative. |
ProbabilityTable |
pointwiseProduct(ProbabilityTable multiplier) |
Factor |
pointwiseProductPOS(Factor multiplier,
RandomVariable... prodVarOrder)
Pointwise Multiplication - Product Order Specified (POS).
see: AIMA3e Figure 14.10 page 527. Pointwise multiplication of this Factor by a given multiplier, creating a new Factor representing the product of the two. |
ProbabilityTable |
pointwiseProductPOS(ProbabilityTable multiplier,
RandomVariable... prodVarOrder) |
void |
setValue(int idx,
double value)
Set the value at a specified index within the distribution.
|
int |
size() |
ProbabilityTable |
sumOut(RandomVariable... vars)
Sum out the provided variables from this Factor creating a new Factor of
the remaining variables with their values updated with the summed out
random variables.
see: AIMA3e page 527. |
java.lang.String |
toString() |
public ProbabilityTable(java.util.Collection<RandomVariable> vars)
public ProbabilityTable(RandomVariable... vars)
public ProbabilityTable(double[] vals,
RandomVariable... vars)
public int size()
public java.util.Set<RandomVariable> getFor()
getFor in interface ProbabilityDistributionpublic boolean contains(RandomVariable rv)
contains in interface Factorcontains in interface ProbabilityDistributionrv - the Random Variable to be checked.public double getValue(java.lang.Object... assignments)
ProbabilityDistributiongetValue in interface ProbabilityDistributionassignments - the values for the random variables comprising the
Distributionpublic double getValue(AssignmentProposition... assignments)
ProbabilityDistributiongetValue in interface ProbabilityDistributionassignments - the assignment propositions for the random variables
comprising the Distributionpublic double[] getValues()
CategoricalDistributiongetValues in interface CategoricalDistributiongetValues in interface FactorCategoricalDistribution.setValue(int, double)public void setValue(int idx,
double value)
CategoricalDistributionsetValue in interface CategoricalDistributionpublic double getSum()
getSum in interface CategoricalDistributionpublic ProbabilityTable normalize()
CategoricalDistributionnormalize in interface CategoricalDistributionpublic int getIndex(java.lang.Object... assignments)
CategoricalDistributiongetIndex in interface CategoricalDistributionassignments - an ordered set of values for the random variables comprising
the Distribution (Note: the order must match the order
of the random variables describing the distribution)CategoricalDistribution.getValues(),
ProbabilityDistribution.getFor()public CategoricalDistribution marginal(RandomVariable... vars)
CategoricalDistributionmarginal in interface CategoricalDistributionvars - the random variables to marginalize/sum out.public CategoricalDistribution divideBy(CategoricalDistribution divisor)
CategoricalDistributiondivideBy in interface CategoricalDistributionpublic CategoricalDistribution multiplyBy(CategoricalDistribution multiplier)
CategoricalDistributionmultiplyBy in interface CategoricalDistributionCategoricalDistribution.multiplyByPOS(CategoricalDistribution,
RandomVariable...)public CategoricalDistribution multiplyByPOS(CategoricalDistribution multiplier, RandomVariable... prodVarOrder)
CategoricalDistributionmultiplyByPOS in interface CategoricalDistributionprodVarOrder - the order the variables comprising the product are to be in.CategoricalDistribution.multiplyBy(CategoricalDistribution)public void iterateOver(CategoricalDistribution.Iterator cdi)
CategoricalDistributioniterateOver in interface CategoricalDistributioncdi - the CategoricalDistribution Iterator to iterate.public void iterateOver(CategoricalDistribution.Iterator cdi, AssignmentProposition... fixedValues)
CategoricalDistributioniterateOver in interface CategoricalDistributioncdi - the CategoricalDistribution Iterator to iteratefixedValues - Fixed values for a subset of the Random Variables comprising
this CategoricalDistribution.public java.util.Set<RandomVariable> getArgumentVariables()
getArgumentVariables in interface Factorpublic ProbabilityTable sumOut(RandomVariable... vars)
Factorpublic Factor pointwiseProduct(Factor multiplier)
FactorpointwiseProduct in interface FactorFactor.pointwiseProductPOS(Factor, RandomVariable...)public Factor pointwiseProductPOS(Factor multiplier, RandomVariable... prodVarOrder)
FactorpointwiseProductPOS in interface FactorprodVarOrder - the order the variables comprising the product are to be in.Factor.pointwiseProduct(Factor)public void iterateOver(Factor.Iterator fi)
FactoriterateOver in interface Factorfi - the Factor Iterator to iterate.public void iterateOver(Factor.Iterator fi, AssignmentProposition... fixedValues)
FactoriterateOver in interface Factorfi - the Factor Iterator to iteratefixedValues - Fixed values for a subset of the Random Variables comprising
this Factor.public void iterateOverTable(ProbabilityTable.Iterator pti)
pti - the ProbabilityTable Iterator to iterate.public void iterateOverTable(ProbabilityTable.Iterator pti, AssignmentProposition... fixedValues)
pti - the ProbabilityTable Iterator to iteratefixedValues - Fixed values for a subset of the Random Variables comprising
this Probability Table.public ProbabilityTable divideBy(ProbabilityTable divisor)
public ProbabilityTable pointwiseProduct(ProbabilityTable multiplier)
public ProbabilityTable pointwiseProductPOS(ProbabilityTable multiplier, RandomVariable... prodVarOrder)
public java.lang.String toString()
toString in class java.lang.Object