|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--BayesianNetworks.DiscreteFunction
Field Summary | |
protected BayesNet |
bn
|
protected double[] |
values
|
protected DiscreteVariable[] |
variables
|
Constructor Summary | |
DiscreteFunction(BayesNet b_n,
int n_vb,
int n_vl)
Constructor for DiscreteFunction. |
|
DiscreteFunction(DiscreteFunction df,
BayesNet b_n)
Constructor for DiscreteFunction. |
|
DiscreteFunction(DiscreteVariable[] for_variables,
DiscreteVariable[] given_variables,
double[] table)
Basic constructor for DiscreteFunction. |
|
DiscreteFunction(DiscreteVariable[] pvs,
double[] v)
Simple constructor for DiscreteFunction. |
|
DiscreteFunction(int n_vb,
int n_vl)
Simple constructor for DiscreteFunction. |
Method Summary | |
double |
evaluate(DiscreteVariable[] pvs,
int[] value_indexes)
Evaluate a function given a (possibly partial) instantiation of variables through the indexes. |
double |
evaluate(int[] value_indexes)
Evaluate a function given a (possibly partial) instantiation of variables through the markers. |
double |
evaluate(java.lang.String[][] variable_value_pairs)
Evaluate a function given a list of pairs (Variable Value) which specifies a value of the function. |
double |
expected_value(DiscreteFunction df)
Obtain expected value of a DiscreteFunction The current implementation is very limited; it assumes that both the DiscreteFunction object and the DiscreteFunctions object has a single variable, and the variable must be the same for both functions. |
int |
get_index(int ind)
Get a DiscreteVariable object with a particular index. |
int |
get_position_from_indexes(DiscreteVariable[] pvs,
int[] variable_indexes)
Get position in a function from a (possibly partial) instantiation of variables through the indexes. |
int |
get_position_from_indexes(int[] variable_indexes)
Get position in a function from a (possibly partial) instantiation of variables through the indexes. |
double |
get_value(int index)
Get a value of the current DiscreteFunction given the position of the value in the array of values. |
DiscreteVariable |
get_variable(int index)
Get a variable in the current DiscreteFunction. |
DiscreteVariable[] |
get_variables()
Get the variables in the current DiscreteFunction. |
boolean |
memberOf(int index)
Check whether an index is present in the function. |
DiscreteFunction |
multiply(DiscreteVariable[] dvs,
DiscreteFunction mult)
Multiply two DiscreteFunction objects. |
void |
normalize_first()
Normalize a probability function (in-place) assuming that it is a conditional distribution for the first variable |
void |
normalize()
Normalize a probability function (in-place). |
int |
number_values()
Return the number of values in the current DiscreteFunction. |
int |
number_variables()
Return the number of DiscreteVariable objects in the current DiscreteFunction. |
double |
posterior_expected_value(DiscreteFunction df)
Obtain posterior expected value of a DiscreteFunction This assumes that the probability values are unnormalized, equal to p(x, e) where e is the evidence. |
void |
set_value(int index,
double v)
Set a value in the current DiscreteFunction given its position in the array of values. |
void |
set_value(java.lang.String[][] variable_value_pairs,
double val)
Set a single value of the probability function. |
void |
set_variable(int index,
DiscreteVariable dv)
Set a DiscreteVariable in the current DiscreteFunction given its position in the array of values. |
DiscreteFunction |
sum_out(DiscreteVariable[] dvs,
boolean[] markers)
Sum out some variables in the function. |
double |
variance(DiscreteFunction df)
Calculate the variance of a DiscreteFunction. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected DiscreteVariable[] variables
protected double[] values
protected BayesNet bn
Constructor Detail |
public DiscreteFunction(DiscreteVariable[] for_variables, DiscreteVariable[] given_variables, double[] table)
public DiscreteFunction(BayesNet b_n, int n_vb, int n_vl)
public DiscreteFunction(DiscreteFunction df, BayesNet b_n)
public DiscreteFunction(int n_vb, int n_vl)
n_vb
- Number of variables in the function.n_vl
- Number of values in the function.public DiscreteFunction(DiscreteVariable[] pvs, double[] v)
pvs
- An array of ProbabilityVariable objects.v
- An array of values for the function.Method Detail |
public boolean memberOf(int index)
public double evaluate(DiscreteVariable[] pvs, int[] value_indexes)
pvs
- The array of DiscreteVariable objects that is used to
compute the position indicated by the markers.value_indexes
- The markers.public int get_position_from_indexes(DiscreteVariable[] pvs, int[] variable_indexes)
public DiscreteFunction sum_out(DiscreteVariable[] dvs, boolean[] markers)
markers
- A boolean vector indicating which variables are
to be summed out. If markers[i] is true, then the
ith variable is to be summed out; if markers[i] is
false, the ith variable is not to be summed out.public DiscreteFunction multiply(DiscreteVariable[] dvs, DiscreteFunction mult)
public void set_value(java.lang.String[][] variable_value_pairs, double val)
public double evaluate(java.lang.String[][] variable_value_pairs)
public double evaluate(int[] value_indexes)
public int get_position_from_indexes(int[] variable_indexes)
public void normalize()
public void normalize_first()
public double expected_value(DiscreteFunction df)
public double posterior_expected_value(DiscreteFunction df)
public double variance(DiscreteFunction df)
public int number_variables()
public int number_values()
public DiscreteVariable[] get_variables()
public DiscreteVariable get_variable(int index)
index
- Position of the variable to be returned
in the array of DiscreteVariable objects.public int get_index(int ind)
ind
- Index of the desired DiscreteVariable.public double get_value(int index)
public void set_value(int index, double v)
index
- The position of the value.v
- The new value.public void set_variable(int index, DiscreteVariable dv)
index
- The position of the value.pv
- The new DiscreteVariable.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |