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.mixture.gibbssampling
Interface GibbsSamplingComponent

All Known Implementing Classes:
  FSDAGModelForGibbsSampling

    public interface GibbsSamplingComponent

This is the interface that any `AbstractModel` has to implement if it should be used in a Gibbs Sampling.
Before starting a series of samplings the method `initModelForSampling(int)` is called.
Then before starting a specific sampling the method `extendSampling(int, boolean)` is called.
In the sampling the method `drawParameters(Sample, double[] )` is used for drawing the parameters from the posterior (and writing them to a file).
After finishing the sampling the method `samplingStopped()` is called.
After a sampling the methods `parseParameterSet(int, int)` and `parseNextParameterSet()` will be used for computing for instance the (log-) likelihoods.
The method `isInSamplingMode()` can be used to check whether an object is currently used for sampling. If the object is in sampling mode, it should not support any other method for changing the parameters than `drawParameters(Sample, double[] )` and `parseParameterSet(int, int)`. Furthermore it is legal to throw an `Exception` when the object is in sampling mode and a method for saving, cloning or training the parameters is called.

Author:
  Berit Haldemann, Jens Keilwagen
See Also:
  `AbstractModel`, `AbstractMixtureModel`, `AbstractMixtureModel.Algorithm.GIBBS_SAMPLING`

Method Summary
`void` | `drawParameters(Sample data, double[] weights)` This method draws the parameters of the model from the a posteriori density.
`void` | `extendSampling(int sampling, boolean append)` This method allows to extend a sampling.
`void` | `initModelForSampling(int starts)` This method initializes the model for the sampling.
`boolean` | `isInSamplingMode()` This method returns `true` if the object is currently used in a sampling, otherwise `false`.
`boolean` | `parseNextParameterSet()` This method allows the user to parse the next set of parameters (from a file).
`boolean` | `parseParameterSet(int sampling, int n)` This method allows the user to parse the set of parameters with index `n` of a certain `sampling` (from a file).
`void` | `samplingStopped()` This method is the opposite of the method `extendSampling(int, boolean)`.

Method Detail

### parseParameterSet

    boolean parseParameterSet(int sampling,
                              int n)
                              throws Exception

  This method allows the user to parse the set of parameters with index `n` of a certain `sampling` (from a file). The internal numbering should start with 0. The parameter set with index 0 is the initial (random) parameter set. It is recommended that a series of parameter sets is accessed by the following lines:

  `for( sampling = 0; sampling < numSampling; sampling++ )
  { boolean b = parseParameterSet( sampling, n );
  while( b )
  {
  //do something
  b = parseNextParameterSet();
  } }
  `

  Parameters:
    `sampling` - the index of the sampling
    `n` - the index of the parameter set
  Returns:
    `true` if the parameter set could be parsed
  Throws:
    `Exception` - if there is a problem with parsing the parameters
  See Also:
    `parseNextParameterSet()`

### parseNextParameterSet

    boolean parseNextParameterSet()

  This method allows the user to parse the next set of parameters (from a file).

  Returns:
    `true` if the parameters could be parsed, otherwise `false`
  See Also:
    `parseParameterSet(int, int)`

### initModelForSampling

    void initModelForSampling(int starts)
                              throws IOException

  This method initializes the model for the sampling. For instance this method can be used to create new files where all parameter sets are stored.

  Parameters:
    `starts` - the number of different sampling starts that will be done
  Throws:
    `IOException` - if something went wrong
  See Also:
    `File.createTempFile(String, String, java.io.File )`

### extendSampling

    void extendSampling(int sampling,
                        boolean append)
                        throws IOException

  This method allows to extend a sampling.

  Parameters:
    `sampling` - the index of the sampling
    `append` - whether to append the sampled parameters to an existing file or to overwrite the file
  Throws:
    `IOException` - if the file could not be handled correctly

### samplingStopped

    void samplingStopped()
                         throws IOException

  This method is the opposite of the method `extendSampling(int, boolean)`. It can be used for closing any streams of writer, ...

  Throws:
    `IOException` - if something went wrong
  See Also:
    `extendSampling(int, boolean)`

### drawParameters

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

  This method draws the parameters of the model from the a posteriori density. It is recommended that the parameters are written to a specific file so that they can later be parsed using the methods of the interface.
  Before using this method the method `initModelForSampling(int)` should be called.

  Parameters:
    `data` - a sample
    `weights` - the (non-negative) weights for each sequence of the sample
  Throws:
    `Exception` - if there is a problem with drawing the parameters, the model is not initialized, ...
  See Also:
    `initModelForSampling(int)`, `parseParameterSet(int, int)`, `parseNextParameterSet()`

### isInSamplingMode

    boolean isInSamplingMode()

  This method returns `true` if the object is currently used in a sampling, otherwise `false`.

  Returns:
    `true` if the object is currently used in a sampling, otherwise `false`

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