public class ProbUtil
extends java.lang.Object
Constructor and Description |
---|
ProbUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
checkValidRandomVariableName(java.lang.String name)
Check if name provided is valid for use as the name of a RandomVariable.
|
static Proposition |
constructConjunction(Proposition[] props)
Convenience method for ensure a conjunction of probabilistic
propositions.
|
static int |
expectedSizeOfCategoricalDistribution(RandomVariable... vars)
Calculated the expected size of a CategoricalDistribution for the
provided random variables.
|
static int |
expectedSizeOfProbabilityTable(RandomVariable... vars)
Calculated the expected size of a ProbabilityTable for the provided
random variables.
|
static java.lang.Object[] |
getEventValuesForParents(Node Xi,
java.util.Map<RandomVariable,java.lang.Object> event)
Get the parent values for the Random Variable Xi from the provided event.
|
static java.lang.Object[] |
getEventValuesForXiGivenParents(Node Xi,
java.util.Map<RandomVariable,java.lang.Object> event)
Get the values for the Random Variable Xi's parents and its own value
from the provided event.
|
static java.lang.Object[] |
getEventValuesForXiGivenParents(Node Xi,
java.lang.Object xDelta,
java.util.Map<RandomVariable,java.lang.Object> event)
Get the values for the Random Variable Xi's parents and its own value
from the provided event.
|
static int[] |
indexesOfValue(RandomVariable[] X,
int idx,
java.util.Map<RandomVariable,java.lang.Object> x)
Calculate the indexes for X[i] into a vector representing the enumeration
of the value assignments for the variables X and their corresponding
assignment in x.
|
static int |
indexOf(RandomVariable[] X,
java.util.Map<RandomVariable,java.lang.Object> x)
Calculate the index into a vector representing the enumeration of the
value assignments for the variables X and their corresponding assignment
in x.
|
static double[] |
mbDistribution(Node Xi,
java.util.Map<RandomVariable,java.lang.Object> event)
Calculate the probability distribution for P(Xi |
mb(Xi)), where mb(Xi) is the Markov Blanket of
Xi.
|
static java.lang.Object |
mbRandomSample(Node Xi,
java.util.Map<RandomVariable,java.lang.Object> event,
Randomizer r)
Get a random sample from P(Xi | mb(Xi)),
where mb(Xi) is the Markov Blanket of Xi.
|
static java.lang.Object |
randomSample(Node Xi,
java.util.Map<RandomVariable,java.lang.Object> event,
Randomizer r)
Get a random sample from P(Xi | parents(Xi))
|
static java.lang.Object |
sample(double probabilityChoice,
RandomVariable Xi,
double[] distribution) |
public static void checkValidRandomVariableName(java.lang.String name) throws java.lang.IllegalArgumentException
name
- proposed for the RandomVariable.java.lang.IllegalArgumentException
- if not a valid RandomVariable name.public static int expectedSizeOfProbabilityTable(RandomVariable... vars)
vars
- null, 0 or more random variables that are to be used to
construct a CategoricalDistribution.CategoricalDistribution.getValues()
public static int expectedSizeOfCategoricalDistribution(RandomVariable... vars)
vars
- null, 0 or more random variables that are to be used to
construct a CategoricalDistribution.CategoricalDistribution.getValues()
public static Proposition constructConjunction(Proposition[] props)
props
- propositions to be combined into a ConjunctiveProposition if
necessary.public static java.lang.Object sample(double probabilityChoice, RandomVariable Xi, double[] distribution)
probabilityChoice
- a probability choice for the sampleXi
- a Random Variable with a finite domain from which a random
sample is to be chosen based on the probability choice.distribution
- Xi's distribution.public static java.lang.Object randomSample(Node Xi, java.util.Map<RandomVariable,java.lang.Object> event, Randomizer r)
Xi
- a Node from a Bayesian network for the Random Variable
Xi.event
- comprising assignments for parents(Xi)r
- a Randomizer for generating a probability choice for the
sample.public static java.lang.Object mbRandomSample(Node Xi, java.util.Map<RandomVariable,java.lang.Object> event, Randomizer r)
Xi
- a Node from a Bayesian network for the Random Variable
Xi.event
- comprising assignments for the Markov Blanket Xi.r
- a Randomizer for generating a probability choice for the
sample.public static double[] mbDistribution(Node Xi, java.util.Map<RandomVariable,java.lang.Object> event)
Xi
- a Node from a Bayesian network for the Random Variable
Xi.event
- comprising assignments for the Markov Blanket Xi.public static java.lang.Object[] getEventValuesForParents(Node Xi, java.util.Map<RandomVariable,java.lang.Object> event)
Xi
- a Node for the Random Variable Xi whose parent values are to
be extracted from the provided event in the correct order.event
- an event containing assignments for Xi's parents.public static java.lang.Object[] getEventValuesForXiGivenParents(Node Xi, java.util.Map<RandomVariable,java.lang.Object> event)
Xi
- a Node for the Random Variable Xi whose parent values and
value are to be extracted from the provided event in the
correct order.event
- an event containing assignments for Xi's parents and its own
value.public static java.lang.Object[] getEventValuesForXiGivenParents(Node Xi, java.lang.Object xDelta, java.util.Map<RandomVariable,java.lang.Object> event)
Xi
- a Node for the Random Variable Xi whose parent values are to
be extracted from the provided event in the correct order.xDelta
- the value for the Random Variable Xi to be assigned to the
values returned.event
- an event containing assignments for Xi's parents and its own
value.public static int indexOf(RandomVariable[] X, java.util.Map<RandomVariable,java.lang.Object> x)
Index Q R T ----- - - - 00: true, A, true 01: true, A, false 02: true, B, true 03: true, B, false 04: true, C, true 05: true, C, false 06: false, A, true 07: false, A, false 08: false, B, true 09: false, B, false 10: false, C, true 11: false, C, falseif x = {Q=true, R='C', T=false} the index returned would be 5.
X
- a list of the Random Variables that would comprise the vector.x
- an assignment for the Random Variables in X.public static int[] indexesOfValue(RandomVariable[] X, int idx, java.util.Map<RandomVariable,java.lang.Object> x)
Index Q R T ----- - - - 00: true, A, true 01: true, A, false 02: true, B, true 03: true, B, false 04: true, C, true 05: true, C, false 06: false, A, true 07: false, A, false 08: false, B, true 09: false, B, false 10: false, C, true 11: false, C, falseif X[i] = R and x = {..., R='C', ...} then the indexes returned would be [4, 5, 10, 11].
X
- a list of the Random Variables that would comprise the vector.idx
- the index into X for the Random Variable whose assignment we
wish to retrieve its indexes for.x
- an assignment for the Random Variables in X.