Class BayesNet

java.lang.Object
  extended by BayesNet

public class BayesNet
extends java.lang.Object

This class loads a Bayes net from a data file. A description of the topology of the Bayes net is stored in public fields, while the conditional probability tables are accessed using a public method. Internally, variables are identified with the integers 0, 1, 2, ..., up to (but not including) the number of variables. The values that each variable can take are also given as integers in a similar manner.


Field Summary
 int[] numParents
          The number of parents of each variable.
 int[] numValues
          The number of values that each variable can take.
 int numVariables
          The number of variables.
 int[][] parents
          The parents of each of the variables.
 java.lang.String[][] valueNames
          The names of the values of each variable.
 java.lang.String[] varName
          The names of each of the variables.
 
Constructor Summary
BayesNet(java.lang.String filename)
          A constructor for constructing a Bayes net by reading in a description from the given data file.
 
Method Summary
 double getCondProb(int x, int[] vals)
          This method can be used to access the conditional probability table of each of the variables.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numVariables

public int numVariables
The number of variables.


varName

public java.lang.String[] varName
The names of each of the variables. varName[i] is the name of variable i.


numValues

public int[] numValues
The number of values that each variable can take. numValues[i] is the number of values that variable i can take.


valueNames

public java.lang.String[][] valueNames
The names of the values of each variable. valueNames[i][j] is the name of variable i's j-th value.


numParents

public int[] numParents
The number of parents of each variable. numParents[i] is the number of parents of variable i.


parents

public int[][] parents
The parents of each of the variables. parents[i][] is a list of the parents of variable i.

Constructor Detail

BayesNet

public BayesNet(java.lang.String filename)
         throws java.io.FileNotFoundException,
                java.io.IOException
A constructor for constructing a Bayes net by reading in a description from the given data file.

Throws:
java.io.FileNotFoundException
java.io.IOException
Method Detail

getCondProb

public double getCondProb(int x,
                          int[] vals)
This method can be used to access the conditional probability table of each of the variables. The method returns the conditional probability of a specified variable x taking a particular value, given the settings of variable x's parents. The first argument to this method is simply the variable x whose (conditional) probability is to be looked up. The second argument vals[] is an integer array of length equal to the total number of variables, where vals[i] is a provided value for variable i. Values must be provided in this array for x and for all of x's parents; all other values in this array will be ignored. The value returned by the method is the conditional probability of variable x taking the value vals[x], given that all of x's parents are set to the values specified in the vals[] array.