DataType
- Type of data in this mixture modelDistributionType
- The type of the internal distributions inside the mixture.@PublicationReference(author="Wikipedia", title="Mixture Model", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Mixture_model") public abstract class LinearMixtureModel<DataType,DistributionType extends Distribution<DataType>> extends AbstractDistribution<DataType>
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<? extends DistributionType> |
distributions
Underlying distributions from which we sample
|
protected double[] |
priorWeights
Weights proportionate by which the distributions are sampled
|
Constructor and Description |
---|
LinearMixtureModel(java.util.Collection<? extends DistributionType> distributions)
Creates a new instance of LinearMixtureModel
|
LinearMixtureModel(java.util.Collection<? extends DistributionType> distributions,
double[] priorWeights)
Creates a new instance of LinearMixtureModel
|
Modifier and Type | Method and Description |
---|---|
LinearMixtureModel<DataType,DistributionType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
int |
getDistributionCount()
Gets the number of distributions in the model
|
java.util.ArrayList<? extends DistributionType> |
getDistributions()
Getter for distributions
|
double[] |
getPriorWeights()
Getter for priorWeights
|
double |
getPriorWeightSum()
Computes the sum of the prior weights
|
DataType |
sample(java.util.Random random)
Draws a single random sample from the distribution.
|
void |
sampleInto(java.util.Random random,
int sampleCount,
java.util.Collection<? super DataType> output)
Draws multiple random samples from the distribution and puts the result
into the given collection.
|
void |
setDistributions(java.util.ArrayList<? extends DistributionType> distributions)
Setter for distributions
|
void |
setPriorWeights(double[] priorWeights)
Getter for priorWeights
|
java.lang.String |
toString() |
sample
protected java.util.ArrayList<? extends DistributionType extends Distribution<DataType>> distributions
protected double[] priorWeights
public LinearMixtureModel(java.util.Collection<? extends DistributionType> distributions)
distributions
- Underlying distributions from which we samplepublic LinearMixtureModel(java.util.Collection<? extends DistributionType> distributions, double[] priorWeights)
distributions
- Underlying distributions from which we samplepriorWeights
- Weights proportionate by which the distributions are sampledpublic LinearMixtureModel<DataType,DistributionType> clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.ArrayList<? extends DistributionType> getDistributions()
public void setDistributions(java.util.ArrayList<? extends DistributionType> distributions)
distributions
- Underlying distributions from which we samplepublic int getDistributionCount()
public DataType sample(java.util.Random random)
Distribution
sample
in interface Distribution<DataType>
sample
in class AbstractDistribution<DataType>
random
- Random-number generator to use in order to generate random numbers.public void sampleInto(java.util.Random random, int sampleCount, java.util.Collection<? super DataType> output)
Distribution
random
- Random number generator to use.sampleCount
- The number of samples to draw. Cannot be negative.output
- The collection to add the samples into.public double[] getPriorWeights()
public void setPriorWeights(double[] priorWeights)
priorWeights
- Weights proportionate by which the distributions are sampledpublic double getPriorWeightSum()