de.jstacs.models
Class UniformModel

java.lang.Object
  extended by de.jstacs.models.AbstractModel
      extended by de.jstacs.models.UniformModel
All Implemented Interfaces:
Model, Storable, Cloneable

public class UniformModel
extends AbstractModel

This class represents an uniform model. Sometimes it's also called uninformed model. It can be used if nothing is known about a statistical process.

Author:
Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.models.AbstractModel
alphabets, length
 
Constructor Summary
UniformModel(AlphabetContainer alphabet)
           
UniformModel(StringBuffer stringBuff)
          The constructor for the Storable interface.
 
Method Summary
 UniformModel clone()
          Follows the conventions of Object's clone-method.
 Sample emitSample(int n, int... lengths)
          This method returns a Sample object containing artificial sequence(s).
 void fromXML(StringBuffer representation)
          This method should only be used by the constructor that works on StringBuffer.
 String getInstanceName()
          Should return a short instance name such as iMM(0), BN(2), ...
 double getLogPriorTerm()
          Returns a value that is proportional to the log of the prior.
 byte getMaximalMarkovOrder()
          This method returns the maximal used markov order if possible.
 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.
 boolean isTrained()
          Returns true.
 String toString()
          Returns the String "".
 StringBuffer toXML()
          This method returns an XML-representation of an instance of the implementing class.
 void train(Sample data, double[] weights)
          Deprecated.  
 
Methods inherited from class de.jstacs.models.AbstractModel
getAlphabetContainer, getCharacteristics, getLength, getLogProbFor, getLogProbFor, getLogProbFor, getLogProbFor, getLogProbFor, getPriorTerm, getProbFor, getProbFor, set, setNewAlphabetContainerInstance, train
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UniformModel

public UniformModel(AlphabetContainer alphabet)
Parameters:
alphabet -

UniformModel

public UniformModel(StringBuffer stringBuff)
             throws NonParsableException
The constructor for the Storable interface.

Parameters:
stringBuff - the StringBuffer
Throws:
NonParsableException - if the StringBuffer is not parsable
Method Detail

clone

public UniformModel 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 AbstractModel
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

getProbFor

public double getProbFor(Sequence sequence,
                         int startpos,
                         int endpos)
                  throws IllegalArgumentException,
                         WrongAlphabetException
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:
IllegalArgumentException
WrongAlphabetException

isTrained

public boolean isTrained()
Returns true.

Returns:
true

fromXML

public void fromXML(StringBuffer representation)
             throws NonParsableException
Description copied from class: AbstractModel
This method should only be used by the constructor that works on StringBuffer. It is the counter part of toXML().

Specified by:
fromXML in class AbstractModel
Parameters:
representation - the representation
Throws:
NonParsableException - if the StringBuffer is not parsable or the representation is conflicting
See Also:
AbstractModel.AbstractModel(StringBuffer)

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML-representation of an instance of the implementing class.

Returns:
the XML-representation

toString

public String toString()
Returns the String "".

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

train

public void train(Sample data,
                  double[] weights)
           throws IOException
Deprecated. 

Does nothing *

Parameters:
data - the given sequences
weights - the weights of the elements, each weight should be non-negative
Throws:
IOException
See Also:
Sample.getElementAt(int), Sample.ElementEnumerator

emitSample

public Sample emitSample(int n,
                         int... lengths)
                  throws 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:
Exception - an Exception should be thrown if the emission did not succeed.
NotTrainedException - a NotTrainedException should be thrown if the model is not trained yet.
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()

getMaximalMarkovOrder

public byte getMaximalMarkovOrder()
                           throws UnsupportedOperationException
Description copied from interface: Model
This method returns the maximal used markov order if possible.

Specified by:
getMaximalMarkovOrder in interface Model
Overrides:
getMaximalMarkovOrder in class AbstractModel
Returns:
maximal used markov order
Throws:
UnsupportedOperationException - if the model can't give a proper answer

getNumericalCharacteristics

public NumericalResultSet getNumericalCharacteristics()
                                               throws Exception
Description copied from interface: Model
Returns the subset of numerical values that are also returned by getCharacteristsics.

Returns:
the numerical characteristics
Throws:
Exception - an Exception is thrown if some of the characteristics could not be defined

getInstanceName

public String getInstanceName()
Description copied from interface: Model
Should return a short instance name such as iMM(0), BN(2), ...

Returns:
a short instance name