jBNC Toolbox

jbnc.util
Class BNTools

java.lang.Object
  extended byjbnc.util.BNTools

public final class BNTools
extends java.lang.Object

Utilities for Bayesian networks.

Since:
June 1, 1999
Author:
Jarek Sacha

Field Summary
static double beta_ijk
          A some small value larger than zero.
 
Constructor Summary
BNTools()
           
 
Method Summary
static double gammaLn(double xx)
          Returns the value ln[ gamma(xx)] for xx > 0 Implementation based on W.H.
static double getASBMParamComponent(BayesianNetworks.BayesNet net, DatasetInt dataset, boolean usePriors, double alphaK)
          Return network parameters component of the asymptotic standard Bayesian measure (ASBM).
static int getNetworkDimension(BayesianNetworks.BayesNet net)
          Returns dimension of a Bayesian network.
protected static InferenceGraphs.InferenceGraphNode[] getNodes(Dataset dataset, InferenceGraphs.InferenceGraph graph)
          Get node names from a graph in an order they appear in the dataset.
protected static void learnParameters_old(BayesianNetworks.BayesNet net, Dataset data, boolean useDirihlet, double alphaK)
          Learns parameters for the current network structure.
static void learnParameters(BayesianNetworks.BayesNet net, DatasetInt data, boolean useDirihlet, double alphaK)
          Learns parameters for the current network structure.
static void learnParameters(BayesianNetworks.BayesNet net, FrequencyCalc fc, boolean useDirihlet, double alphaK)
          Learns parameters for the current network structure.
static void main(java.lang.String[] args)
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beta_ijk

public static final double beta_ijk
A some small value larger than zero.

See Also:
Constant Field Values
Constructor Detail

BNTools

public BNTools()
Method Detail

getNetworkDimension

public static int getNetworkDimension(BayesianNetworks.BayesNet net)
                               throws java.lang.Exception
Returns dimension of a Bayesian network.

Dimension of a Bayesian network: Let X be a set of random variables and B be a Bayesian network defined over X. The dimension of this network, Dim(B), is the number of free parameters required to completely specify the joint probability distribution of X.

E. Castillo, J. M. Gutierrez and A. S. Hadi, Expert Systems and Probabilistic Network Models , Springer, 1997. p.486.

Parameters:
net - Description of Parameter
Returns:
The NetworkDimension value
Throws:
java.lang.Exception - .

getASBMParamComponent

public static final double getASBMParamComponent(BayesianNetworks.BayesNet net,
                                                 DatasetInt dataset,
                                                 boolean usePriors,
                                                 double alphaK)
                                          throws java.lang.Exception
Return network parameters component of the asymptotic standard Bayesian measure (ASBM).

q = sumi =1...n sumj =1... qi sumk =1...ri Nijk log Nijk / Nij

where Nijk means that variable Xi is in configuration k and parents of variable Xi are in configuration j .

E. Castillo, J. M. Gutierrez and A. S. Hadi, Expert Systems and Probabilistic Network Models , Springer, 1997. p.494, eq.(11.28).

Parameters:
net - Description of Parameter
dataset - Description of Parameter
usePriors - Description of Parameter
alphaK - Description of Parameter
Returns:
The ASBMParamComponent value
Throws:
java.lang.Exception - .

gammaLn

public static double gammaLn(double xx)
                      throws java.lang.Exception
Returns the value ln[ gamma(xx)] for xx > 0 Implementation based on W.H. Press et al. Numerical Recipes in C , 2nd Ed., Cambridge University Press, 1992.

Parameters:
xx -
Returns:
Throws:
java.lang.Exception - When xx <= 0.

learnParameters

public static void learnParameters(BayesianNetworks.BayesNet net,
                                   FrequencyCalc fc,
                                   boolean useDirihlet,
                                   double alphaK)
                            throws java.lang.Exception
Learns parameters for the current network structure. Existing network parameters are replaced with the new ones. This method can use "uniform" Dirihlet priors.

Parameters:
net - Bayesian network.
useDirihlet - Indicates whether Dirihlet priors should be used for network parameters.
alphaK - alphak parameter for Dirihlet priors. All alphak are assumed to be the same and greater than zero.
fc - Description of Parameter
Throws:
java.lang.Exception

learnParameters

public static void learnParameters(BayesianNetworks.BayesNet net,
                                   DatasetInt data,
                                   boolean useDirihlet,
                                   double alphaK)
                            throws java.lang.Exception
Learns parameters for the current network structure. Existing network parameters are replaced with the new ones. This method can use "uniform" Dirihlet priors.

Parameters:
net - Bayesian network.
useDirihlet - Indicates whether Dirihlet priors should be used for network parameters.
alphaK - alphak parameter for Dirihlet priors. All alphak are assumed to be the same and greater than zero.
data - Description of Parameter
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
Description of the Method

Parameters:
args - Description of Parameter

getNodes

protected static InferenceGraphs.InferenceGraphNode[] getNodes(Dataset dataset,
                                                               InferenceGraphs.InferenceGraph graph)
                                                        throws java.lang.Exception
Get node names from a graph in an order they appear in the dataset.

Parameters:
dataset - Description of Parameter
graph - Description of Parameter
Returns:
The Nodes value
Throws:
java.lang.Exception - Description of Exception

learnParameters_old

protected static void learnParameters_old(BayesianNetworks.BayesNet net,
                                          Dataset data,
                                          boolean useDirihlet,
                                          double alphaK)
                                   throws java.lang.Exception
Learns parameters for the current network structure. Existing network parameters are replaced with the new ones. This method can use "uniform" Dirihlet priors.

Parameters:
net - Bayesian network.
useDirihlet - Indicates whether Dirihlet priors should be used for network parameters.
alphaK - alphak parameter for Dirihlet priors. All alphak are assumed to be the same and greater than zero.
data - Description of Parameter
Throws:
java.lang.Exception

SourceForge.net Logo