Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

riso.distributions
Class OrGate  view OrGate download OrGate.java

java.lang.Object
  extended byriso.distributions.AbstractConditionalDistribution
      extended byriso.distributions.OrGate
All Implemented Interfaces:
ConditionalDistribution, java.io.Serializable

public class OrGate
extends AbstractConditionalDistribution

An object of this class represents an "or" gate. The output of the gate is 1 if any input is 1, and zero otherwise.


Field Summary
(package private)  int ninputs
          This is the number of inputs for this or gate.
 
Fields inherited from class riso.distributions.AbstractConditionalDistribution
associated_variable
 
Constructor Summary
OrGate()
          Default constructor for a or gate.
OrGate(int ninputs_in)
          This constructor sets the number of inputs.
 
Method Summary
 java.lang.Object clone()
          Return a copy of this object.
 java.lang.String format_string(java.lang.String leading_ws)
          Create a description of this or gate as a string.
 Distribution get_density(double[] c)
          For a given value c of the parents, return a distribution which represents p(x|C=c).
 int ndimensions_child()
          Return the number of dimensions of the child variable.
 int ndimensions_parent()
          Return the number of dimensions of the parent variables.
 double p(double[] x, double[] c)
          Compute the probability that the output is 1 (if x[0]==1) or the output is 0 (if x[0]==0).
 void pretty_input(riso.general.SmarterTokenizer st)
          Read in a OrGate from an input stream.
 double[] random(double[] c)
          Return an instance of a random variable from this distribution.
 
Methods inherited from class riso.distributions.AbstractConditionalDistribution
get_nstates, parse_string, pretty_output, set_variable, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ninputs

int ninputs
This is the number of inputs for this or gate. This is either specified directly (in a constructor) or by counting the number of parents of the associated variable.

Constructor Detail

OrGate

public OrGate()
Default constructor for a or gate. The number of inputs is set to 0; it is assumed that a variable will be associated with this distribution before any methods that need the number of inputs are called.


OrGate

public OrGate(int ninputs_in)
This constructor sets the number of inputs.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Return a copy of this object.

Specified by:
clone in interface ConditionalDistribution
Overrides:
clone in class AbstractConditionalDistribution

ndimensions_child

public int ndimensions_child()
Return the number of dimensions of the child variable.


ndimensions_parent

public int ndimensions_parent()
Return the number of dimensions of the parent variables.


get_density

public Distribution get_density(double[] c)
                         throws java.lang.Exception
For a given value c of the parents, return a distribution which represents p(x|C=c). Executing get_density(c). p(x) will yield the same result as p(x,c).


p

public double p(double[] x,
                double[] c)
         throws java.lang.Exception
Compute the probability that the output is 1 (if x[0]==1) or the output is 0 (if x[0]==0). If x[0]==1, the return value is 1 if any c[i] is 1, otherwise return 0. Otherwise the return value is 1 minus the value computed for x[0]==1.


random

public double[] random(double[] c)
                throws java.lang.Exception
Return an instance of a random variable from this distribution.


pretty_input

public void pretty_input(riso.general.SmarterTokenizer st)
                  throws java.io.IOException
Read in a OrGate from an input stream. This is intended for input from a human-readable source; this is different from object serialization. The input looks like this:
   { [ninputs ninputs-value] }
 

Overrides:
pretty_input in class AbstractConditionalDistribution

format_string

public java.lang.String format_string(java.lang.String leading_ws)
                               throws java.io.IOException
Create a description of this or gate as a string. If this distribution is associated with a variable, the number of inputs is not put into the description.