## org.biojava.bio.dist
Class AbstractDistribution

    java.lang.Object
      |
      +--org.biojava.bio.dist.AbstractDistribution

Direct Known Subclasses:
  DNADistribution, PairDistribution, SimpleDistribution, UniformDistribution

public abstract class AbstractDistribution
extends java.lang.Object
implements Distribution

An abstract implementation of Distribution.

You will need to over-ride `getWeight()` for a simple implementation. You may also wish to over-ride the other methods if the default implementation is not suitable.

Note that, in this implementation, the `setWeight` implementation throws an exception. The `registerWithTrainer` method registers an `IgnoreCountsTrainer`. To make an `AbstractDistribution` subclass trainable, both these methods must be overridden.

Author:
  Matthew Pocock, Thomas Down

Constructor Summary
`AbstractDistribution()`

Method Summary
`protected double` `getAmbiguityWeight(Symbol amb)` Performs the standard munge to handle ambiguity symbols.
`abstract Distribution` `getNullModel()` Retrieve the null model Distribution that this Distribution recognizes.
`void` `registerWithTrainer(DistributionTrainerContext dtc)` Register an IgnoreCountsTrainer instance as the trainer for this distribution.
`Symbol` `sampleSymbol()` Sample a symbol from this state's probability distribution.
`void` `setWeight(Symbol sym, double weight)` Set the weight of a given symbol in this distribution.

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

Constructor Detail

### AbstractDistribution

    public AbstractDistribution()

Method Detail

### setWeight

    public void setWeight(Symbol sym,
                          double weight)
                   throws IllegalSymbolException,
                          java.lang.UnsupportedOperationException

  Set the weight of a given symbol in this distribution. This implementation simply throws an exception.
  Specified by:
    setWeight in interface Distribution
  Tags copied from interface: Distribution
  Parameters:
    `s` - the Symbol emitted
    `w` - the probability of emitting that symbol
  Throws:
    IllegalSymbolException - if s is not from this state's alphabet, or if it is an ambiguity symbol and the implementation can't handle this case
    java.lang.UnsupportedOperationException - if this state does not allow weights to be tampered with

### getAmbiguityWeight

    protected double getAmbiguityWeight(Symbol amb)
                                 throws IllegalSymbolException

  Performs the standard munge to handle ambiguity symbols.
  Parameters:
    `amb` - the AmbiguitySymbol to find the probability of
  Returns:
    the probability that one of the symbols matching amb was emitted
  Throws:
    IllegalSymbolException - if for any reason the symbols within amb are not recognized by this state

### getNullModel

    public abstract Distribution getNullModel()

  Retrieve the null model Distribution that this Distribution recognizes.
  Returns:
    the apropriate null model

### sampleSymbol

    public Symbol sampleSymbol()
                        throws BioError

  Description copied from interface: Distribution
  Sample a symbol from this state's probability distribution.
  Specified by:
    sampleSymbol in interface Distribution
  Tags copied from interface: Distribution
  Returns:
    the symbol sampled

### registerWithTrainer

    public void registerWithTrainer(DistributionTrainerContext dtc)

  Register an IgnoreCountsTrainer instance as the trainer for this distribution. Override this if you wish to implement a trainable distribution.
  Specified by:
    registerWithTrainer in interface Distribution
  Tags copied from interface: Distribution
  Parameters:
    `dtc` - the DistributionTrainerContext with witch to register a trainer