@PublicationReference(author="Wikipedia", title="Chi-square distribution", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Chi-square_distribution") public class ChiSquareDistribution extends AbstractClosedFormSmoothUnivariateDistribution
Modifier and Type | Class and Description |
---|---|
static class |
ChiSquareDistribution.CDF
Cumulative Distribution Function (CDF) of a Chi-Square Distribution
|
static class |
ChiSquareDistribution.PDF
PDF of the Chi-Square distribution
|
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_DEGREES_OF_FREEDOM
Default degrees of freedom, 2.0.
|
Constructor and Description |
---|
ChiSquareDistribution()
Default constructor.
|
ChiSquareDistribution(ChiSquareDistribution other)
Copy constructor
|
ChiSquareDistribution(double degreesOfFreedom)
Creates a new instance of ChiSquareDistribution
|
Modifier and Type | Method and Description |
---|---|
ChiSquareDistribution |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
void |
convertFromVector(Vector parameters)
Sets the parameter of the chi-square PDF
|
Vector |
convertToVector()
Returns the parameter of the chi-square PDF
|
ChiSquareDistribution.CDF |
getCDF()
Gets the CDF of a scalar distribution.
|
double |
getDegreesOfFreedom()
Getter for degrees of freedom
|
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.
|
ChiSquareDistribution.PDF |
getProbabilityFunction()
Gets the distribution function associated with this Distribution,
either the PDF or PMF.
|
double |
getVariance()
Gets the variance of the distribution.
|
static java.util.ArrayList<java.lang.Double> |
sample(double degreesOfFreedom,
java.util.Random random,
int numSamples)
Samples from a Chi-Square distribution with the given degrees of freedom
|
static double[] |
sampleAsDoubles(double degreesOfFreedom,
java.util.Random random,
int numSamples)
Samples from a Chi-Square distribution with the given degrees of freedom
|
void |
sampleInto(java.util.Random random,
double[] output,
int start,
int length)
Samples values from this distribution as an array of doubles.
|
void |
setDegreesOfFreedom(double degreesOfFreedom)
Setter for degrees of freedom
|
getMean, sampleAsDouble, sampleAsDoubles, sampleInto
sample, sample
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sample, sample
public static final double DEFAULT_DEGREES_OF_FREEDOM
public ChiSquareDistribution()
public ChiSquareDistribution(double degreesOfFreedom)
degreesOfFreedom
- Number of degrees of freedom in the distribution,
must be greater than 0.0public ChiSquareDistribution(ChiSquareDistribution other)
other
- ChiSquareDistribution to copypublic ChiSquareDistribution 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 Vectorizable
clone
in interface CloneableSerializable
clone
in class AbstractClosedFormUnivariateDistribution<java.lang.Double>
public double getDegreesOfFreedom()
public void setDegreesOfFreedom(double degreesOfFreedom)
degreesOfFreedom
- Number of degrees of freedom in the distribution,
must be greater than 0.0public double getMeanAsDouble()
UnivariateDistribution
public double getVariance()
UnivariateDistribution
public Vector convertToVector()
public void convertFromVector(Vector parameters)
parameters
- 1-dimensional Vector containing the degrees of freedompublic void sampleInto(java.util.Random random, double[] output, int start, int length)
SmoothUnivariateDistribution
random
- 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 static double[] sampleAsDoubles(double degreesOfFreedom, java.util.Random random, int numSamples)
degreesOfFreedom
- Degrees of freedom of the Chi-Square distributionrandom
- Random number generatornumSamples
- Number of samples to generatepublic static java.util.ArrayList<java.lang.Double> sample(double degreesOfFreedom, java.util.Random random, int numSamples)
degreesOfFreedom
- Degrees of freedom of the Chi-Square distributionrandom
- Random number generatornumSamples
- Number of samples to generatepublic ChiSquareDistribution.CDF getCDF()
UnivariateDistribution
public ChiSquareDistribution.PDF getProbabilityFunction()
ComputableDistribution
public java.lang.Double getMinSupport()
UnivariateDistribution
public java.lang.Double getMaxSupport()
UnivariateDistribution