## org.biojava.bio.dist
Class SimpleDistribution

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojava.bio.dist.AbstractDistribution
              org.biojava.bio.dist.SimpleDistribution

All Implemented Interfaces:
  Serializable, Distribution, Changeable

Direct Known Subclasses:
  UntrainableDistribution

    public class SimpleDistribution

extends AbstractDistribution
implements Serializable

A simple implementation of a distribution, which works with any finite alphabet.

Since:
  1.0
Author:
  Matthew Pocock, Thomas Down, Mark Schreiber
See Also:
  Serialized Form

Nested Class Summary
`protected class` `SimpleDistribution.Trainer` A simple implementation of a trainer for this class.

Nested classes/interfaces inherited from interface org.biojava.bio.dist.Distribution
`Distribution.NullModelForwarder`

Field Summary

Fields inherited from class org.biojava.bio.dist.AbstractDistribution
`nullModelForwarder`

Fields inherited from interface org.biojava.bio.dist.Distribution
`NULL_MODEL, WEIGHTS`

Constructor Summary
`SimpleDistribution(Distribution dist)` make an instance of SimpleDistribution with weights identical to the specified Distribution.
`SimpleDistribution(FiniteAlphabet alphabet)` make an instance of SimpleDistribution for the specified Alphabet.

Method Summary
`Alphabet` `getAlphabet()` The alphabet from which this spectrum emits symbols.
`Distribution` `getNullModel()` Retrieve the null model Distribution that this Distribution recognizes.
`double` `getWeightImpl(AtomicSymbol s)` Override this method to implement getting the weight for an atomic symbol.
`protected double[]` `getWeights()` Get the underlying array that stores the weights.
`protected boolean` `hasWeights()` Indicate whether the weights array has been allocated yet.
`void` `registerWithTrainer(DistributionTrainerContext dtc)` Register an SimpleDistribution.Trainer instance as the trainer for this distribution.
`protected void` `setNullModelImpl(Distribution nullModel)` Implement this to set the null model.
`protected void` `setWeightImpl(AtomicSymbol s, double w)` Implement this to actually set the weight.

Methods inherited from class org.biojava.bio.dist.AbstractDistribution
`equals, getChangeSupport, getWeight, hashCode, sampleSymbol, setNullModel, setWeight`

Methods inherited from class org.biojava.utils.AbstractChangeable
`addChangeListener, addChangeListener, generateChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener`

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

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Constructor Detail

### SimpleDistribution

    public SimpleDistribution(FiniteAlphabet alphabet)

  make an instance of SimpleDistribution for the specified Alphabet.

### SimpleDistribution

    public SimpleDistribution(Distribution dist)

  make an instance of SimpleDistribution with weights identical to the specified Distribution.

  Parameters:
    `dist` - Distribution to copy the weights from.

Method Detail

### getAlphabet

    public Alphabet getAlphabet()

  Description copied from interface: `Distribution`
  The alphabet from which this spectrum emits symbols.

  Specified by:
    `getAlphabet` in interface `Distribution`
  Returns:
    the Alphabet associated with this spectrum

### getNullModel

    public Distribution getNullModel()

  Description copied from interface: `Distribution`
  Retrieve the null model Distribution that this Distribution recognizes.

  Specified by:
    `getNullModel` in interface `Distribution`
  Returns:
    the apropriate null model

### setNullModelImpl

    protected void setNullModelImpl(Distribution nullModel)
                             throws IllegalAlphabetException,
                                    ChangeVetoException

  Description copied from class: `AbstractDistribution`
  Implement this to set the null model.

  You should not inform any change listeners in this method. All of that work has been done for you.

  Specified by:
    `setNullModelImpl` in class `AbstractDistribution`
  Parameters:
    `nullModel` - the new null model Distribution
  Throws:
    `IllegalAlphabetException` - if the null model is for the wrong alphabet
    `ChangeVetoException` - if your implementation wishes to block this opperation

### hasWeights

    protected boolean hasWeights()

  Indicate whether the weights array has been allocated yet.

  Returns:
    true if the weights are allocated

### getWeights

    protected double[] getWeights()

  Get the underlying array that stores the weights.

  Modifying this will modify the state of the distribution.

  Returns:
    the weights array

### getWeightImpl

    public double getWeightImpl(AtomicSymbol s)
                         throws IllegalSymbolException

  Description copied from class: `AbstractDistribution`
  Override this method to implement getting the weight for an atomic symbol. You should just do what is necessary to fetch state. All the work with exceptions and listeners will have been handled for you.

  Specified by:
    `getWeightImpl` in class `AbstractDistribution`
  Parameters:
    `s` - the AtomicSymbol to get the weight for
  Returns:
    the weight
  Throws:
    `IllegalSymbolException` - if sym is not known

### setWeightImpl

    protected void setWeightImpl(AtomicSymbol s,
                                 double w)
                          throws IllegalSymbolException,
                                 ChangeVetoException

  Description copied from class: `AbstractDistribution`
  Implement this to actually set the weight.

  Do not inform any listeners. This has already been done for you. Just update state.

  Specified by:
    `setWeightImpl` in class `AbstractDistribution`
  Parameters:
    `s` - the AtomicSymbol to update for
    `w` - the new weight for that symbol
  Throws:
    `IllegalSymbolException` - if the symbol is not known
    `ChangeVetoException` - if the change is to be prevented

### registerWithTrainer

    public void registerWithTrainer(DistributionTrainerContext dtc)

  Register an SimpleDistribution.Trainer instance as the trainer for this distribution.

  Specified by:
    `registerWithTrainer` in interface `Distribution`
  Overrides:
    `registerWithTrainer` in class `AbstractDistribution`
  Parameters:
    `dtc` - the context to register with