@PublicationReference(author="Wikipedia", title="Gamma distribution", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Gamma_distribution") public class GammaDistribution extends AbstractClosedFormSmoothUnivariateDistribution implements EstimableDistribution<java.lang.Double,GammaDistribution>
| Modifier and Type | Class and Description |
|---|---|
static class |
GammaDistribution.CDF
CDF of the Gamma distribution
|
static class |
GammaDistribution.MomentMatchingEstimator
Computes the parameters of a Gamma distribution by the
Method of Moments
|
static class |
GammaDistribution.PDF
Closed-form PDF of the Gamma distribution
|
static class |
GammaDistribution.WeightedMomentMatchingEstimator
Estimates the parameters of a Gamma distribution using the matching
of moments, not maximum likelihood.
|
| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_SCALE
Default scale, 1.0.
|
static double |
DEFAULT_SHAPE
Default shape, 1.0.
|
| Constructor and Description |
|---|
GammaDistribution()
Default constructor.
|
GammaDistribution(double shape,
double scale)
Creates a new instance of GammaDistribution
|
GammaDistribution(GammaDistribution other)
Copy constructor
|
| Modifier and Type | Method and Description |
|---|---|
GammaDistribution |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
void |
convertFromVector(Vector parameters)
Sets the parameters of the distribution
|
Vector |
convertToVector()
Gets the parameters of the distribution
|
GammaDistribution.CDF |
getCDF()
Gets the CDF of a scalar distribution.
|
GammaDistribution.MomentMatchingEstimator |
getEstimator()
Gets an estimator associated with this distribution.
|
java.lang.Double |
getMaxSupport()
Gets the minimum support (domain or input) 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.
|
GammaDistribution.PDF |
getProbabilityFunction()
Gets the distribution function associated with this Distribution,
either the PDF or PMF.
|
double |
getRate()
Gets the rate parameter, which is just the inverse of the scale parameter.
|
double |
getScale()
Getter for scale
|
double |
getShape()
Getter for shape
|
double |
getVariance()
Gets the variance of the distribution.
|
static double |
sample(double shape,
double scale,
java.util.Random random)
Provides a single sample from a Gamma distribution with the given shape
and scale.
|
static java.util.ArrayList<java.lang.Double> |
sample(double shape,
double scale,
java.util.Random random,
int numSamples)
Efficiently samples from a Gamma distribution given by the
shape and scale parameters.
|
static double |
sampleAsDouble(double shape,
double scale,
java.util.Random random)
Efficiently samples from a Gamma distribution given by the
shape and scale parameters.
|
double |
sampleAsDouble(java.util.Random random)
Samples a value from this distribution as a double.
|
static double[] |
sampleAsDoubles(double shape,
double scale,
java.util.Random random,
int numSamples)
Efficiently samples from a Gamma distribution given by the
shape and scale parameters.
|
static void |
sampleInto(double shape,
double scale,
java.util.Random random,
double[] output,
int start,
int length)
Efficiently samples from a Gamma distribution given by the
shape and scale parameters.
|
void |
sampleInto(java.util.Random random,
double[] output,
int start,
int length)
Samples values from this distribution as an array of doubles.
|
static double |
sampleStandard(double shape,
java.util.Random random)
Provides a single sample from a Gamma distribution with the given shape
and a scale of 1.
|
void |
setRate(double rate)
Sets the rate parameter, which is just the inverse of the scale parameter.
|
void |
setScale(double scale)
Setter for scale
|
void |
setShape(double shape)
Setter for shape
|
java.lang.String |
toString() |
getMean, sampleAsDoubles, sampleIntosample, sampleequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsample, sample, sampleIntopublic static final double DEFAULT_SHAPE
public static final double DEFAULT_SCALE
public GammaDistribution()
public GammaDistribution(double shape,
double scale)
shape - Shape parameter of the Gamma distribution, often written as "k",
must be greater than zeroscale - Scale parameters of the Gamma distribution, often written as "theta",
must be greater than zero.
Note that this is the INVERSE of what octave uses!!public GammaDistribution(GammaDistribution other)
other - GammaDistribution to copypublic GammaDistribution 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 AbstractClosedFormUnivariateDistribution<java.lang.Double>public double getShape()
public void setShape(double shape)
shape - Shape parameter of the Gamma distribution, often written as "k",
must be greater than zeropublic double getScale()
public void setScale(double scale)
scale - Scale parameters of the Gamma distribution, often written as "theta",
must be greater than zero.
Note that this is the INVERSE of what octave uses!!public double getRate()
public void setRate(double rate)
rate - The rate parameter (1.0 / scale). Must be greater than 0.0.public double getMeanAsDouble()
UnivariateDistributiongetMeanAsDouble in interface UnivariateDistribution<java.lang.Double>public double getVariance()
UnivariateDistributiongetVariance in interface UnivariateDistribution<java.lang.Double>public Vector convertToVector()
convertToVector in interface Vectorizablepublic void convertFromVector(Vector parameters)
convertFromVector in interface Vectorizableparameters - 2-dimensional Vector with (shape scale)public static java.util.ArrayList<java.lang.Double> sample(double shape,
double scale,
java.util.Random random,
int numSamples)
shape - Shape parameter of the Gamma distribution, often written as "k",
must be greater than zeroscale - Scale parameters of the Gamma distribution, often written as "theta",
must be greater than zero.
Note that this is the INVERSE of what octave uses!!random - Random number generatornumSamples - Number of samples to generatepublic static double sampleAsDouble(double shape,
double scale,
java.util.Random random)
shape - Shape parameter of the Gamma distribution, often written as "k",
must be greater than zeroscale - Scale parameters of the Gamma distribution, often written as "theta",
must be greater than zero.
Note that this is the INVERSE of what octave uses!!random - Random number generatorpublic static double[] sampleAsDoubles(double shape,
double scale,
java.util.Random random,
int numSamples)
shape - Shape parameter of the Gamma distribution, often written as "k",
must be greater than zeroscale - Scale parameters of the Gamma distribution, often written as "theta",
must be greater than zero.
Note that this is the INVERSE of what octave uses!!random - Random number generatornumSamples - Number of samples to generatepublic static void sampleInto(double shape,
double scale,
java.util.Random random,
double[] output,
int start,
int length)
shape - Shape parameter of the Gamma distribution, often written as "k",
must be greater than zeroscale - Scale parameters of the Gamma distribution, often written as "theta",
must be greater than zero.
Note that this is the INVERSE of what octave uses!!random - Random number generatoroutput - Array to write samples from Gamma distribution into.start - Starting point in output array to add samples.length - Number of samples to generatepublic static double sample(double shape,
double scale,
java.util.Random random)
shape - Shape parameter of the Gamma distribution, often written as "k",
must be greater than zero.scale - Scale parameters of the Gamma distribution, often written as "theta",
must be greater than zero.random - Random number generator to use.public static double sampleStandard(double shape,
java.util.Random random)
shape - Shape parameter of the Gamma distribution, often written as "k",
must be greater than zero.random - Random number generator to use.public double sampleAsDouble(java.util.Random random)
SmoothUnivariateDistributionsampleAsDouble in interface SmoothUnivariateDistributionsampleAsDouble in class AbstractClosedFormSmoothUnivariateDistributionrandom - Random number generator to use.public 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 GammaDistribution.CDF getCDF()
UnivariateDistributiongetCDF in interface ClosedFormUnivariateDistribution<java.lang.Double>getCDF in interface SmoothUnivariateDistributiongetCDF in interface UnivariateDistribution<java.lang.Double>public GammaDistribution.PDF getProbabilityFunction()
ComputableDistributiongetProbabilityFunction in interface ComputableDistribution<java.lang.Double>getProbabilityFunction in interface SmoothUnivariateDistributionpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Double getMinSupport()
UnivariateDistributiongetMinSupport in interface UnivariateDistribution<java.lang.Double>public java.lang.Double getMaxSupport()
UnivariateDistributiongetMaxSupport in interface UnivariateDistribution<java.lang.Double>public GammaDistribution.MomentMatchingEstimator getEstimator()
EstimableDistributiongetEstimator in interface EstimableDistribution<java.lang.Double,GammaDistribution>