public class SimpleDistributionTrainerContext extends Object implements DistributionTrainerContext, Serializable
Constructor and Description |
---|
SimpleDistributionTrainerContext()
Create a new context with no initial distributions or trainers.
|
Modifier and Type | Method and Description |
---|---|
void |
addCount(Distribution dist,
Symbol sym,
double times)
Registers that sym was counted in this state.
|
void |
clearCounts()
Clears all of the counts to zero.
|
double |
getCount(Distribution dist,
Symbol sym)
Return the number of counts of a particular symbol which will be used
to train the specified distribution.
|
double |
getNullModelWeight()
Return the number of pseudocounts added to the distribution when training.
|
DistributionTrainer |
getTrainer(Distribution dist)
Return the Distribution trainer object from the current context.
|
void |
registerDistribution(Distribution dist)
Register a distribution object with this context.
|
void |
registerTrainer(Distribution dist,
DistributionTrainer trainer)
Register a Distribution and an associated DistributionTrainer object.
|
void |
setNullModelWeight(double nullModelWeight)
Set the number of pseudocounts to add when training the distribution.
|
void |
train()
Trains the Distribution, given a null model.
|
public SimpleDistributionTrainerContext()
public double getNullModelWeight()
DistributionTrainerContext
getNullModelWeight
in interface DistributionTrainerContext
public void setNullModelWeight(double nullModelWeight)
DistributionTrainerContext
setNullModelWeight
in interface DistributionTrainerContext
nullModelWeight
- the new null model weightpublic void registerDistribution(Distribution dist)
DistributionTrainerContext
Register a distribution object with this context.
This method is a request to the context to register dist. If dist is already registered then this method should do nothing. If it is not registered, then it should invoke dist.registerWithTrainer
registerDistribution
in interface DistributionTrainerContext
dist
- the Distribution to registerpublic void registerTrainer(Distribution dist, DistributionTrainer trainer)
DistributionTrainerContext
Register a Distribution and an associated DistributionTrainer object.
In the registerWithTrainer method of a Distribution, it should associate itself with a trainer using this method.
registerTrainer
in interface DistributionTrainerContext
dist
- the distribution to be registered.trainer
- the distribution's trainer object to be registered.public DistributionTrainer getTrainer(Distribution dist)
DistributionTrainerContext
getTrainer
in interface DistributionTrainerContext
dist
- the Distribution whose trainer is requiredpublic void addCount(Distribution dist, Symbol sym, double times) throws IllegalSymbolException
DistributionTrainerContext
Registers that sym was counted in this state.
This method may be called multiple times with the same symbol. In this case, the times should be summed.
addCount
in interface DistributionTrainerContext
dist
- the Distribution that the symbol was associated withsym
- the Symbol seentimes
- the number of times to addIllegalSymbolException
- if sym is not recognised by distpublic double getCount(Distribution dist, Symbol sym) throws IllegalSymbolException
DistributionTrainerContext
getCount
in interface DistributionTrainerContext
dist
- the Distribution to return counts forsym
- the symbol to get the count forIllegalSymbolException
- if the symbol is not accepted by the
distributionpublic void train() throws ChangeVetoException
DistributionTrainerContext
Trains the Distribution, given a null model.
This will use the information collected with multiple addCount calls, and the null model to generate the new weights.
train
in interface DistributionTrainerContext
ChangeVetoException
- if any of the distributions can't be trainedpublic void clearCounts()
DistributionTrainerContext
clearCounts
in interface DistributionTrainerContext
Copyright © 2014 BioJava. All rights reserved.