pt.tumba.ngram.bayes
Class ProbabilityFunction

java.lang.Object
  extended by pt.tumba.ngram.bayes.DiscreteFunction
      extended by pt.tumba.ngram.bayes.ProbabilityFunction
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
QBProbabilityFunction

public class ProbabilityFunction
extends DiscreteFunction
implements java.io.Serializable

***************************************************************

See Also:
Serialized Form

Field Summary
protected  BayesNet bn
           
protected  java.util.Vector properties
           
 
Fields inherited from class pt.tumba.ngram.bayes.DiscreteFunction
values, variables
 
Constructor Summary
ProbabilityFunction()
          Default constructor for a ProbabilityFunction.
ProbabilityFunction(BayesNet b_n, DiscreteVariable[] pvs, double[] v, java.util.Vector prop)
          Constructor for ProbabilityFunction.
ProbabilityFunction(BayesNet b_n, int n_vb, int n_vl, java.util.Vector prop)
          Constructor for ProbabilityFunction.
ProbabilityFunction(DiscreteFunction df, BayesNet b_n)
          Constructor for ProbabilityFunction.
ProbabilityFunction(DiscreteFunction df, double[] new_values)
          Constructor for ProbabilityFunction.
 
Method Summary
 void add_property(java.lang.String prop)
          Add a property to the current ProbabilityFunction.
 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 ProbabilityFunction object and the DiscreteFunctions object has a single variable, and the variable must be the same for both functions.
 java.util.Enumeration get_enumerated_properties()
          Get an Enumeration with the properties of the current ProbabilityFunction.
 int get_position_from_indexes(int[] variable_indexes)
          Get position in a function from a (possibly partial) instantiation of variables through the indexes.
 java.util.Vector get_properties()
          Get the properties of the current ProbabilityFunction.
 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 print(java.io.PrintStream out)
          Print method.
(package private)  void process_properties()
           
 void remove_property(int i)
          Remove a property in a given position in the current ProbabilityFunction.
 void remove_property(java.lang.String prop)
          Remove a property in the current ProbabilityFunction.
 void save_xml_0_3(java.io.PrintStream out)
          Save the contents of a ProbabilityFunction object into a PrintStream in the XMLBIF v0.3 format.
 void save_xml(java.io.PrintStream out)
          Save the contents of a ProbabilityFunction object into a PrintStream.
 void set_properties(java.util.Vector prop)
          Set the properties.
 void set_value(java.lang.String[][] variable_value_pairs, double val)
          Set a single value of the probability function.
 double variance(DiscreteFunction df)
          Calculate the variance of a DiscreteFunction.
 
Methods inherited from class pt.tumba.ngram.bayes.DiscreteFunction
evaluate, get_index, get_indexes, get_position_from_indexes, get_value, get_values, get_variable, get_variables, memberOf, multiply, normalize_first, normalize, number_values, number_variables, print, same_variables, set_value, set_values, set_variable, sum_out
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

protected java.util.Vector properties

bn

protected BayesNet bn
Constructor Detail

ProbabilityFunction

public ProbabilityFunction()
Default constructor for a ProbabilityFunction.


ProbabilityFunction

public ProbabilityFunction(BayesNet b_n,
                           int n_vb,
                           int n_vl,
                           java.util.Vector prop)
Constructor for ProbabilityFunction.


ProbabilityFunction

public ProbabilityFunction(BayesNet b_n,
                           DiscreteVariable[] pvs,
                           double[] v,
                           java.util.Vector prop)
Constructor for ProbabilityFunction.


ProbabilityFunction

public ProbabilityFunction(DiscreteFunction df,
                           double[] new_values)
Constructor for ProbabilityFunction.


ProbabilityFunction

public ProbabilityFunction(DiscreteFunction df,
                           BayesNet b_n)
Constructor for ProbabilityFunction.

Method Detail

process_properties

void process_properties()

set_value

public void set_value(java.lang.String[][] variable_value_pairs,
                      double val)
Set a single value of the probability function.


evaluate

public 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.


evaluate

public double evaluate(int[] value_indexes)
Evaluate a function given a (possibly partial) instantiation of variables through the markers. The markers indicate which variables are present in the function to be evaluated.


get_position_from_indexes

public int get_position_from_indexes(int[] variable_indexes)
Get position in a function from a (possibly partial) instantiation of variables through the indexes.


expected_value

public double expected_value(DiscreteFunction df)
Obtain expected value of a DiscreteFunction The current implementation is very limited; it assumes that both the ProbabilityFunction object and the DiscreteFunctions object has a single variable, and the variable must be the same for both functions.


posterior_expected_value

public 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. The current implementation is very limited; it assumes that both the ProbabilityFunction object and the DiscreteFunctions object has a single variable, and the variable must be the same for both functions.


variance

public double variance(DiscreteFunction df)
Calculate the variance of a DiscreteFunction. The current implementation is very limited; it assumes that both the ProbabilityFunction object and the DiscreteFunctions object has a single variable, and the variable must be the same for both functions.


save_xml_0_3

public void save_xml_0_3(java.io.PrintStream out)
Save the contents of a ProbabilityFunction object into a PrintStream in the XMLBIF v0.3 format.


save_xml

public void save_xml(java.io.PrintStream out)
Save the contents of a ProbabilityFunction object into a PrintStream.


print

public void print(java.io.PrintStream out)
Print method.

Overrides:
print in class DiscreteFunction

get_properties

public java.util.Vector get_properties()
Get the properties of the current ProbabilityFunction.


set_properties

public void set_properties(java.util.Vector prop)
Set the properties.


get_enumerated_properties

public java.util.Enumeration get_enumerated_properties()
Get an Enumeration with the properties of the current ProbabilityFunction.


add_property

public void add_property(java.lang.String prop)
Add a property to the current ProbabilityFunction.


remove_property

public void remove_property(java.lang.String prop)
Remove a property in the current ProbabilityFunction.


remove_property

public void remove_property(int i)
Remove a property in a given position in the current ProbabilityFunction.

Parameters:
i - Position of the property.