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

Quick Search    Search Deep

riso.distributions
Class ConditionalGaussian  view ConditionalGaussian download ConditionalGaussian.java

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

public class ConditionalGaussian
extends AbstractConditionalDistribution

An instance of this class represents a conditional Gaussian distribution. The dependence enters only through the mean, which is a linear combination the parents plus an offset. The variance is constant.

Writing the marginal means of the child and parent variables, respectively, as mu(1) and mu(2), and the respective marginal variances as Sigma(11) and Sigma(22), and the covariance as Sigma(12), then the conditional mean mu(1|2) and conditional variance Sigma(1|2) are as follows.

     mu(1|2) = mu(1) + Sigma(12) Sigma(22)^{-1} (X(2)-mu(2))
     Sigma(1|2) = Sigma(11) - Sigma(12) Sigma(22)^{-1} Sigma(21)
 
where the parent variables appear as X(2). These parameters are named as follows in the description for an object of this type:
     conditional-mean-multiplier == Sigma(12) Sigma(22)^{-1}
     conditional-mean-offset     == mu(1) - Sigma(12) Sigma(22)^{-1} mu(2)
     conditional-variance        == Sigma(1|2)
 
In the code, these three parameters are called a_mu_1c2, b_mu_1c2, and Sigma_1c2, respectively.


Field Summary
 double[][] a_mu_1c2
          Multiplier for conditional mean calculation.
(package private)  java.lang.String a_mu_1c2_string
           
 double[] b_mu_1c2
          Offset for conditional mean calculation.
(package private)  java.lang.String b_mu_1c2_string
           
 double det_Sigma_1c2
           
 double[][] Sigma_1c2
          Covariance matrix of the conditional distribution.
 double[][] Sigma_1c2_inverse
           
(package private)  java.lang.String Sigma_1c2_string
           
 
Fields inherited from class riso.distributions.AbstractConditionalDistribution
associated_variable
 
Constructor Summary
ConditionalGaussian()
          Do-nothing constructor, so Class.forName works.
 
Method Summary
 void check_matrices()
          If vectors and matrices descriptions have not yet been parsed, do so now.
 java.lang.Object clone()
          Return a deep copy of this object.
 java.lang.String format_string(java.lang.String leading_ws)
          Create a description of this distribution model 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 density at the point x.
(package private) static double[][] parse_matrix(java.lang.String s, int nrows, int ncols)
           
(package private) static double[] parse_vector(java.lang.String s, int n)
           
 void pretty_input(riso.general.SmarterTokenizer st)
          Read in a ConditionalGaussian 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

Sigma_1c2_inverse

public double[][] Sigma_1c2_inverse

det_Sigma_1c2

public double det_Sigma_1c2

Sigma_1c2_string

java.lang.String Sigma_1c2_string

a_mu_1c2_string

java.lang.String a_mu_1c2_string

b_mu_1c2_string

java.lang.String b_mu_1c2_string

b_mu_1c2

public double[] b_mu_1c2
Offset for conditional mean calculation. The conditional mean is calculated as a_mu_1c2 * x2 + b_mu_1c2, where x2 is the vector of variables on which we are conditioning.


a_mu_1c2

public double[][] a_mu_1c2
Multiplier for conditional mean calculation.


Sigma_1c2

public double[][] Sigma_1c2
Covariance matrix of the conditional distribution. This matrix has number of rows and columns equal to the dimension of the child.

Constructor Detail

ConditionalGaussian

public ConditionalGaussian()
Do-nothing constructor, so Class.forName works.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Return a deep copy of this object. If the matrices haven't already been parsed, parse the description strings now.

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. If there is more than one parent, this is the sum of the 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 density at the point x.


random

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


format_string

public java.lang.String format_string(java.lang.String leading_ws)
                               throws java.io.IOException
Create a description of this distribution model as a string. This is a full description, suitable for printing, containing newlines and indents.


pretty_input

public void pretty_input(riso.general.SmarterTokenizer st)
                  throws java.io.IOException
Read in a ConditionalGaussian from an input stream. This is intended for input from a human-readable source; this is different from object serialization.

Overrides:
pretty_input in class AbstractConditionalDistribution

check_matrices

public void check_matrices()
                    throws java.io.IOException,
                           java.rmi.RemoteException
If vectors and matrices descriptions have not yet been parsed, do so now. If they are already parsed, do nothing.


parse_matrix

static double[][] parse_matrix(java.lang.String s,
                               int nrows,
                               int ncols)
                        throws java.io.IOException

parse_vector

static double[] parse_vector(java.lang.String s,
                             int n)
                      throws java.io.IOException