|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.tumba.ngram.bayes.DiscreteFunction
public class DiscreteFunction
Field Summary | |
---|---|
protected double[] |
values
|
protected DiscreteVariable[] |
variables
|
Constructor Summary | |
---|---|
DiscreteFunction()
Default constructor for a 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. |
int |
get_index(int ind)
Get a DiscreteVariable object with a particular index. |
int[] |
get_indexes()
Get an array with all the indexes of the DiscreteVariable objects in the current DiscreteFunction. |
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. |
double |
get_value(int index)
Get a value of the current DiscreteFunction given the position of the value in the array of values. |
double[] |
get_values()
Get all values of the current DiscreteFunction. |
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 function (in-place) assuming that it is a conditional distribution for the first variable |
void |
normalize()
Normalize a 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. |
void |
print()
Print method for DiscreteFunction. |
void |
print(java.io.PrintStream out)
Print method for DiscreteFunction into a PrintStream. |
(package private) boolean |
same_variables(DiscreteFunction df)
|
void |
set_value(int index,
double v)
Set a value in the current DiscreteFunction given its position in the array of values. |
void |
set_values(double[] vs)
Set the values in the DiscreteFunction. |
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. |
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
Constructor Detail |
---|
public DiscreteFunction()
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)
boolean same_variables(DiscreteFunction df)
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 normalize()
public void normalize_first()
public void print()
public void print(java.io.PrintStream out)
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_indexes()
public int get_index(int ind)
ind
- Index of the desired DiscreteVariable.public double[] get_values()
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_values(double[] vs)
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: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |