|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--techniques.BN.Variable
Represents a variable in a bayes net, and beyond the variable name stores the possible values and the conditional probability table for the variable. By default variables have 2 given values (1) Boolean.FALSE, and (2) Boolean.TRUE . These values are mapped to numbers (from 0 to getNumValues) and programs need to explicitly retrieve the given values for the non numeric values.
Constructor Summary | |
Variable(String varName)
|
|
Variable(String varName,
Object[] varGivenValues)
|
Method Summary | |
Object |
clone()
|
Object |
getGivenValue(int ndx)
Maps number to given value |
Object[] |
getGivenValues()
Returns all given values (in an array with indices representing the mapping from number to given value) |
String |
getName()
Returns variable name |
int |
getNumValues()
Returns number of values used by variable |
Variable[] |
getParents()
|
double |
getProb(HashMap evidence)
Used to get the probability values for the given variable evidence. |
double |
getProb(int value,
HashMap evidence)
Used to get the probability values for the given variable vaue index/number and evidence |
ProbTable |
getProbTable()
Returns cond. |
int |
getValNdx(Object givenValue)
Maps given value to number |
int[] |
getValues()
Just returns all numbers from 0 to getNumValues() |
void |
setParent(Variable var)
set parents for the conditional prob. |
void |
setParents(Variable[] vars)
set parents for the conditional prob. |
void |
setProb(int i,
double[] valueCPT)
Used to set the condition probability table values for the given variable vaue index/number |
void |
setTrueProb(double[] trueCPT)
Used to set the condition probability table values by only providing values for variable given value being Boolean.TRUE (the method calculate values for Boolean.FALSE). |
String |
toString()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Variable(String varName)
varName
- - name of variablepublic Variable(String varName, Object[] varGivenValues)
varName
- - name of variablevarGivenValues
- - given values of the variables (note all variables
have values which are integers, and given values, for example Boolean.TRUE
and Boolean.FALSEMethod Detail |
public String getName()
public ProbTable getProbTable()
public String toString()
toString
in class Object
public Object[] getGivenValues()
public int[] getValues()
public int getValNdx(Object givenValue)
public Object getGivenValue(int ndx)
public int getNumValues()
public void setParent(Variable var)
public void setParents(Variable[] vars)
public Variable[] getParents()
public void setTrueProb(double[] trueCPT)
public void setProb(int i, double[] valueCPT)
public double getProb(int value, HashMap evidence)
value
- - variable value index/numberevidence
- - a map of variables to their value indicespublic double getProb(HashMap evidence)
public Object clone() throws CloneNotSupportedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |