Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.models.discrete.inhomogeneous
Class DAGModel

    java.lang.Object
      de.jstacs.models.AbstractModel
          de.jstacs.models.discrete.DiscreteGraphicalModel
              de.jstacs.models.discrete.inhomogeneous.InhomogeneousDGM
                  de.jstacs.models.discrete.inhomogeneous.DAGModel

All Implemented Interfaces:
  InstantiableFromParameterSet, Model, Storable, Cloneable

Direct Known Subclasses:
  BayesianNetworkModel, FSDAGModel

    public abstract class DAGModel

extends InhomogeneousDGM

The abstract class for directed acyclic graphical models.

Author:
  Jens Keilwagen

Field Summary
`protected InhCondProb[]` | `constraints` The constraints for the model.

Fields inherited from class de.jstacs.models.discrete.inhomogeneous.InhomogeneousDGM
`DEFAULT_STREAM, sostream`

Fields inherited from class de.jstacs.models.discrete.DiscreteGraphicalModel
`params, trained`

Fields inherited from class de.jstacs.models.AbstractModel
`alphabets, length`

Constructor Summary
`protected` | `DAGModel(IDGMParameterSet params)` This is the main constructor.
`protected` | `DAGModel(StringBuffer xml)` This is the constructor for `Storable`.

Method Summary
`protected static boolean` | `checkAcyclic(int length, int[][] graph)` This method checks whether a given graph is acyclic.
`DAGModel` | `clone()` Follows the conventions of `Object`'s clone-method.
`protected void` | `createConstraints(int[][] structure)` This method creates the constraints for a given structure.
`protected void` | `drawParameters(Sample data, double[] weights)` This method draws the parameter of the model from the likelihood respectively posterior.
`Sample` | `emitSample(int n, int... lengths)` This method returns a Sample object containing artificial sequence(s).
`protected void` | `estimateParameters(Sample data, double[] weights)` This method estimates the parameter of the model from the likelihood respectively posterior.
`protected StringBuffer` | `getFurtherModelInfos()`
`double` | `getLogPriorTerm()` Returns a value that is proportional to the log of the prior.
`double` | `getLogProbFor(Sequence sequence, int startpos, int endpos)` Returns the logarithm of the probability of the given sequence given the model.
`NumericalResultSet` | `getNumericalCharacteristics()` Returns the subset of numerical values that are also returned by `getCharacteristsics`.
`double` | `getProbFor(Sequence sequence, int startpos, int endpos)` Returns the probability of the given sequence given the model.
`String` | `getStructure()` Returns a string representation of the graph.
`protected void` | `setFurtherModelInfos(StringBuffer xml)` This method replaces the internal model infos with those from the StringBuffer.
`String` | `toString()` Should give a simple representation (text) of the model as String.

Methods inherited from class de.jstacs.models.discrete.inhomogeneous.InhomogeneousDGM
`check, set, setOutputStream`

Methods inherited from class de.jstacs.models.discrete.DiscreteGraphicalModel
`fromXML, getCurrentParameterSet, getDescription, getESS, getXMLTag, isTrained, toXML`

Methods inherited from class de.jstacs.models.AbstractModel
`getAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogProbFor, getLogProbFor, getMaximalMarkovOrder, getPriorTerm, getProbFor, getProbFor, set, setNewAlphabetContainerInstance, train`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface de.jstacs.models.Model
`getInstanceName, train`

Field Detail

### constraints

    protected InhCondProb[] constraints

  The constraints for the model.

Constructor Detail

### DAGModel

    protected DAGModel(IDGMParameterSet params)
                throws CloneNotSupportedException,
                       IllegalArgumentException,
                       NonParsableException

  This is the main constructor. It creates an new instance from the given parameter set.

  Parameters:
    `params` - the parameter set
  Throws:
    `CloneNotSupportedException` - if the parameter set could not be cloned
    `IllegalArgumentException` - if the parameter set is not instantiated
    `NonParsableException` - if the parameter set is not parsable

### DAGModel

    protected DAGModel(StringBuffer xml)
                throws NonParsableException

  This is the constructor for `Storable`.

  Parameters:
    `xml` - the xml representation
  Throws:
    `NonParsableException` - if the representation could not be parsed.

Method Detail

### clone

    public DAGModel clone()
                   throws CloneNotSupportedException

  Description copied from class: `AbstractModel`
  Follows the conventions of `Object`'s clone-method.

  Specified by:
    `clone` in interface `Model`
  Overrides:
    `clone` in class `InhomogeneousDGM`
  Returns:
    an object, that is a copy of the current `AbstractModel` (the member-`AlphabetContainer` isn't deeply cloned since it is assumed to be immutable). The type of the returned object is defined by the class `X` directly inherited from `AbstractModel`. Hence `X`'s clone-method should work as:
    1. `Object o = (X)super.clone();` 2. all additional member variables of `o` defined by `X` that are not of simple data-types like int, double, ... , have to be deeply copied 3. `return o`
  Throws:
    `CloneNotSupportedException`

### emitSample

    public Sample emitSample(int n,
                             int... lengths)
                      throws NotTrainedException,
                             Exception

  Description copied from interface: `Model`
  This method returns a Sample object containing artificial sequence(s).
  There are 2 different possibilities to create a sample for a model with length 0.
  1. `emitSample( int n, int l )` should return a sample with `n` sequences of length `l`.
  2. `emitSample( int n, int[] l )` should return a sample with `n` sequences which have a sequence length corresponding to the entry in the array
  There are 2 different possibilities to create a sample for a model with length greater than 0. `emitSample( int n )` and `emitSample( int n, null )` should return a sample with `n` sequences of length of the model (`Model.getLength()`)
  The standard implementation throws an Exception.

  Specified by:
    `emitSample` in interface `Model`
  Overrides:
    `emitSample` in class `AbstractModel`
  Parameters:
    `n` - the number of sequences that should be contained in the returned sample
    `lengths` - the length of the sequences for a homogeneous model; for an inhomogeneous model this parameter should be `null` or an array of size 0.
  Returns:
    Sample containing the artificial sequence(s)
  Throws:
    `NotTrainedException` - a NotTrainedException should be thrown if the model is not trained yet.
    `Exception` - an Exception should be thrown if the emission did not succeed.
  See Also:
    `Sample`

### getLogPriorTerm

    public double getLogPriorTerm()
                           throws Exception

  Description copied from interface: `Model`
  Returns a value that is proportional to the log of the prior. For ML 0 should be returned.

  Returns:
    a value that is proportional to the log of the prior
  Throws:
    `Exception` - if something went wrong
  See Also:
    `Model.getPriorTerm()`

### getLogProbFor

    public double getLogProbFor(Sequence sequence,
                                int startpos,
                                int endpos)
                         throws NotTrainedException,
                                Exception

  Description copied from interface: `Model`
  Returns the logarithm of the probability of the given sequence given the model. If a least one random variable is continuous the value of density function is returned.
  For more details see `Model.getProbFor(Sequence, int, int)`

  Specified by:
    `getLogProbFor` in interface `Model`
  Overrides:
    `getLogProbFor` in class `AbstractModel`
  Parameters:
    `sequence` - the sequence
    `startpos` - the start position
    `endpos` - the last position to be taken into account
  Returns:
    the logarithm of probability or the value of the density function of the part of the given sequence given the model
  Throws:
    `NotTrainedException` - a NotTrainedException should be thrown if the model is not trained yet.
    `Exception` - an Exception should be thrown if the sequence could not be handled (e.g. startpos > endpos, endpos > sequence.length, ...) by the model
  See Also:
    `Model.getProbFor(Sequence, int, int)`

### getNumericalCharacteristics

    public NumericalResultSet getNumericalCharacteristics()

  Description copied from interface: `Model`
  Returns the subset of numerical values that are also returned by `getCharacteristsics`.

  Returns:
    the numerical characteristics

### getProbFor

    public double getProbFor(Sequence sequence,
                             int startpos,
                             int endpos)
                      throws NotTrainedException,
                             Exception

  Description copied from interface: `Model`
  Returns the probability of the given sequence given the model. If a least one random variable is continuous the value of density function is returned.
  It extends the possibility given by the method getProbFor(Sequence sequence, int startpos) by the fact, that the model could be e.g. homogeneous and therefore the length of the sequences, whose probability should be returned, is not fixed. Additionally the end position of the part of the given sequence is given and the probability of the part from position `startpos` to `endpos` (inclusive) should be returned.
  The `length` and `alphabets` define the type of data that can be modeled and therefore both has to be checked.

  Parameters:
    `sequence` - the sequence
    `startpos` - the start position
    `endpos` - the last position to be taken into account
  Returns:
    the probability or the value of the density function of the part of the given sequence given the model
  Throws:
    `NotTrainedException` - a NotTrainedException should be thrown if the model is not trained yet.
    `Exception` - an Exception should be thrown if the sequence could not be handled (e.g. startpos > endpos, endpos > sequence.length, ...) by the model

### getStructure

    public String getStructure()
                        throws NotTrainedException

  Description copied from class: `InhomogeneousDGM`
  Returns a string representation of the graph.

  Specified by:
    `getStructure` in class `InhomogeneousDGM`
  Returns:
    a string representation of the graph
  Throws:
    `NotTrainedException` - if the structure is not set, this can only be the case if the model is not trained

### toString

    public String toString()

  Description copied from interface: `Model`
  Should give a simple representation (text) of the model as String.

  Specified by:
    `toString` in interface `Model`
  Overrides:
    `toString` in class `DiscreteGraphicalModel`
  Returns:
    the representation as String

### checkAcyclic

    protected static boolean checkAcyclic(int length,
                                          int[][] graph)

  This method checks whether a given graph is acyclic.

  Parameters:
    `length` - the sequence length (which corresponds to the number of nodes in the graph)
    `graph` - the specified graph
  Returns:
    `true` if the given graph is acyclic

### createConstraints

    protected void createConstraints(int[][] structure)

  This method creates the constraints for a given structure.

  Parameters:
    `structure` - the specified structure

### drawParameters

    protected void drawParameters(Sample data,
                                  double[] weights)
                           throws Exception

  This method draws the parameter of the model from the likelihood respectively posterior.

  Parameters:
    `data` - the data
    `weights` - the weights for the sequences in the data
  Throws:
    `Exception` - if something went wrong while counting or drawing

### estimateParameters

    protected void estimateParameters(Sample data,
                                      double[] weights)
                               throws Exception

  This method estimates the parameter of the model from the likelihood respectively posterior.

  Parameters:
    `data` - the data
    `weights` - the weights for the sequences in the data
  Throws:
    `Exception` - if something went wrong while counting or estimating
  See Also:
    `drawParameters(Sample, double[])`

### getFurtherModelInfos

    protected StringBuffer getFurtherModelInfos()

  Specified by:
    `getFurtherModelInfos` in class `DiscreteGraphicalModel`
  Returns:
    the model infos like parameters of the distribution ... in xml format
  See Also:
    `DiscreteGraphicalModel.toXML()`

### setFurtherModelInfos

    protected void setFurtherModelInfos(StringBuffer xml)
                                 throws NonParsableException

  Description copied from class: `DiscreteGraphicalModel`
  This method replaces the internal model infos with those from the StringBuffer.

  Specified by:
    `setFurtherModelInfos` in class `DiscreteGraphicalModel`
  Parameters:
    `xml` - contains the model infos like parameters of the distribution ... in xml format
  Throws:
    `NonParsableException` - if the StringBuffer could not be parsed
  See Also:
    `DiscreteGraphicalModel.fromXML(StringBuffer)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD