@CodeReview(reviewer="Kevin R. Dixon", date="2009-10-20", changesNeeded=true, comments={"Fixed some missing javadoc.","General style fixes.","Added task to figure out a way to avoid storing weights in matrix.","Generally looks good.","Some argument checks need to be more complete"}, response=@CodeReviewResponse(date="2009-10-20",respondent="Dan Morrow",comments={"added additional test coverage","added more argument checks"},moreChangesNeeded=false)) @PublicationReference(author="Wikipedia", title="Mixture Model", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Mixture_density") public class ScalarMixtureDensityModel extends LinearMixtureModel<java.lang.Double,SmoothUnivariateDistribution> implements SmoothUnivariateDistribution
| Modifier and Type | Class and Description |
|---|---|
static class |
ScalarMixtureDensityModel.CDF
CDFof the SMDM
|
static class |
ScalarMixtureDensityModel.EMLearner
An EM learner that estimates a mixture model from data
|
static class |
ScalarMixtureDensityModel.PDF
PDF of the SMDM
|
distributions, priorWeights| Constructor and Description |
|---|
ScalarMixtureDensityModel()
Creates a new instance of ScalarMixtureDensityModel
|
ScalarMixtureDensityModel(java.util.Collection<? extends SmoothUnivariateDistribution> distributions)
Creates a new instance of ScalarMixtureDensityModel
|
ScalarMixtureDensityModel(java.util.Collection<? extends SmoothUnivariateDistribution> distributions,
double[] priorWeights)
Creates a new instance of ScalarMixtureDensityModel
|
ScalarMixtureDensityModel(ScalarMixtureDensityModel other)
Copy constructor
|
ScalarMixtureDensityModel(SmoothUnivariateDistribution... distributions)
Creates a new instance of ScalarMixtureDensityModel
|
| Modifier and Type | Method and Description |
|---|---|
ScalarMixtureDensityModel |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
void |
convertFromVector(Vector parameters)
Converts the object from a Vector of parameters.
|
Vector |
convertToVector()
Converts the object to a vector.
|
ScalarMixtureDensityModel.CDF |
getCDF()
Gets the CDF of a scalar distribution.
|
java.lang.Double |
getMaxSupport()
Gets the minimum support (domain or input) of the distribution.
|
java.lang.Double |
getMean()
Gets the arithmetic mean, or "first central moment" or "expectation",
of the distribution.
|
double |
getMeanAsDouble()
Gets the mean of the distribution as a double.
|
java.lang.Double |
getMinSupport()
Gets the minimum support (domain or input) of the distribution.
|
ScalarMixtureDensityModel.PDF |
getProbabilityFunction()
Gets the distribution function associated with this Distribution,
either the PDF or PMF.
|
double |
getVariance()
Gets the variance of the distribution.
|
double |
sampleAsDouble(java.util.Random random)
Samples a value from this distribution as a double.
|
double[] |
sampleAsDoubles(java.util.Random random,
int count)
Samples values from this distribution as an array of doubles.
|
void |
sampleInto(java.util.Random random,
double[] output,
int start,
int length)
Samples values from this distribution as an array of doubles.
|
getDistributionCount, getDistributions, getPriorWeights, getPriorWeightSum, sample, sampleInto, setDistributions, setPriorWeights, toStringsampleequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsample, sample, sampleIntopublic ScalarMixtureDensityModel()
public ScalarMixtureDensityModel(SmoothUnivariateDistribution... distributions)
distributions - Distributions that comprise the SMDM with equal prior weightpublic ScalarMixtureDensityModel(java.util.Collection<? extends SmoothUnivariateDistribution> distributions)
distributions - Distributions that comprise the SMDM with equal prior weightpublic ScalarMixtureDensityModel(java.util.Collection<? extends SmoothUnivariateDistribution> distributions, double[] priorWeights)
distributions - Distributions that comprise the SMDMpriorWeights - Weights proportionate by which the distributions are sampledpublic ScalarMixtureDensityModel(ScalarMixtureDensityModel other)
other - SMDM to copypublic ScalarMixtureDensityModel clone()
AbstractCloneableSerializableObject 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 Vectorizableclone in interface CloneableSerializableclone in class LinearMixtureModel<java.lang.Double,SmoothUnivariateDistribution>public Vector convertToVector()
VectorizableconvertToVector in interface Vectorizablepublic void convertFromVector(Vector parameters)
VectorizableconvertFromVector in interface Vectorizableparameters - The parameters to incorporate.public java.lang.Double getMinSupport()
UnivariateDistributiongetMinSupport in interface UnivariateDistribution<java.lang.Double>public java.lang.Double getMaxSupport()
UnivariateDistributiongetMaxSupport in interface UnivariateDistribution<java.lang.Double>public java.lang.Double getMean()
DistributionWithMeangetMean in interface DistributionWithMean<java.lang.Double>getMean in interface SmoothUnivariateDistributionpublic double getMeanAsDouble()
UnivariateDistributiongetMeanAsDouble in interface UnivariateDistribution<java.lang.Double>@PublicationReference(author="Wikipedia", title="Mixture Model", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Mixture_density") public double getVariance()
UnivariateDistributiongetVariance in interface UnivariateDistribution<java.lang.Double>public double sampleAsDouble(java.util.Random random)
SmoothUnivariateDistributionsampleAsDouble in interface SmoothUnivariateDistributionrandom - Random number generator to use.public double[] sampleAsDoubles(java.util.Random random,
int count)
SmoothUnivariateDistributionsampleAsDoubles in interface SmoothUnivariateDistributionrandom - Random number generator to use.count - The number of values to sample. Cannot be negativepublic void sampleInto(java.util.Random random,
double[] output,
int start,
int length)
SmoothUnivariateDistributionsampleInto in interface SmoothUnivariateDistributionrandom - Random number generator to use.output - The array to write the result into. Cannot be null.start - The offset in the array to start writing at. Cannot be negative.length - The number of values to sample. Cannot be negative.public ScalarMixtureDensityModel.PDF getProbabilityFunction()
ComputableDistributiongetProbabilityFunction in interface ComputableDistribution<java.lang.Double>getProbabilityFunction in interface SmoothUnivariateDistributionpublic ScalarMixtureDensityModel.CDF getCDF()
UnivariateDistributiongetCDF in interface ClosedFormUnivariateDistribution<java.lang.Double>getCDF in interface SmoothUnivariateDistributiongetCDF in interface UnivariateDistribution<java.lang.Double>